|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Combo Boxes & query
I have a main table and a form built on it
From the form there are two combo list boxes The first one is for Type (of animal) The second is for Breed (ex. of cats or dogs) I have another table which the combo boxes are using that list fields "type" and "breed" I have a query built on the table to filter by type. If "type" chosen on form is "dog", then the combo box for breed should pull only dog breeds from the query and offer only those options for the drop down to choose breed. Same situation for cat, where if type=cat, then choices for breed drop down should include only cat breeds. How on earth to I achieve this goal? I've tried many things although I'm not sure how to do any of them correctly Thanks for any help |
|
#2
|
|||
|
|||
|
The basic principle here is to cascade your comboboxes. For example your combobox that represents "type" will have the row source based on the table that has your type and breed. The combobox for the breed will have the rowsource based on a query of the same table. In the query you will set the criteria under the "type" field to your "type" combobox, something like this:
Forms!FormName.Combobox....using the correct form and combobox names. Then in the After Update Event of your "type" combobox enter Me.ComboBoxBreed.Requery ... use the correct name of your breed combobox This will requery your combobox to show only those records filtered by the "type" from the "type" combobox. If you still run into difficulties, post back with the correct table, query, and form control names in your application and I can get you more specific code examples. lwells |
|
#3
|
|||
|
|||
|
I'm still having problems. I know I'm not doing something right.
Anyway, here are the names. frm_Registered based on tbl_Registered Combo box "Type" from tbl_Breeds with field "Type" combo box "Breeds" from qry_TypeBreeds" I made the changes and here's the status now... Combo box "Type" repeats or is not grouped (ex. Dog, Dog, Dog, Dog, Cat, Cat, ... and on and on, one for each record) Row Source says this: SELECT [tbl_Breeds].[Type] FROM tbl_Breeds; Also, with the same combo box "Type" after selecting an option it says the database can't find the macro 'Me.' I put this in "After Update": Me.Breed.Requery I feel so stupid. I know this is easier than I'm making it but I can't get past this block. Thank you so much for your help lwells[/QUOTE] |
|
#4
|
|||
|
|||
|
I made a few adjustments during a logical moment. I looked at the row source in th sql view and after grouping the field the first problem was solved. I also put the Me.Breed.Requery in the form of a macro since it was looking for one. That fixed the second problem. Thank you again for everything. I've been stuck on this most of the day.
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Combo Boxes & query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|