Select to view content in your preferred language

How to select by attributes by using 2 comboboxes? (VBA)

1797
2
11-18-2013 05:51 AM
geomatic
Emerging Contributor
Hi Experts,
I am trying to create query userform by using comboboxes and a button.
I would like to choose attributes from joined table by using comboboxes.
Aim of the study is select objects which have values between first and second combobox values.
comboboxes should populated by attributes.
After selecting first value in combobox, second combobox value should be populated remaining values.
For Example:
I want to select objects by Total Points attributes. (eg: starts from 0 to 100)
Eg. in first combobox we choose 23, then second combobox should populate itself from 23 to 100.
So if we choose 23 and 51, objects should be selected which have total points between 23 and 51 (23,24,25 ...... 50,51)
To sum up i want to create query such as select by attributes:
[Total] < 23 And [Total] > 51

Thanks for your helps.
0 Kudos
2 Replies
DuncanHornby
MVP Notable Contributor
Now you may have been using a fictitious example but would a Textbox be a more appropriate control to enter these numbers? If you select '23' no one will want to keep scrolling down to say 99 every time. Would be much more intuitive to simply type it.

The key interfaces are IFeatureSelection and IQueryFilter�??.
0 Kudos
RichardFairhurst
MVP Alum
I believe comboboxes allow a user to type a value without scrolling, which can then be validated against the list in the combobox.  Also, the real formula that the selections would return the results described would be:

[Total] <= 23 And [Total] >= 51

Not

[Total] < 23 And [Total] > 51

I believe you need to look at something like the combobox SelectedItem and ListItems interface and use a for loop to read the list of the first combobox from the selected Index number to the bottom and use the second combox's Clear and AddItme methods.  Anyway, VBA is being depricated, so don't develop using that.   I can't even find the help files for VBA anymore to recall how I used to do this.  Move on to VB.Net or another .Net language.
0 Kudos