Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field on form based on query 1

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
I have 3 comboboxes on my form. Main_Category, Second_Category and Third_Category, these fields are based on a query.

I currently simply have the second and third category visible set to false and then when the Main category is chosen the second category is visible and third when a second category is chosen.

Not sure if this is possible or not but sometimes there is not an option for a third category. Is it possible to only show that third category combobox when the query returns a value? The third Category choices are always dependent on what is chosen in the first two fields.

Hope that made sense.

Thank you!

Paul
 
Are these cascading combo boxes so the row sources change based on the previous selection? If so, you should be able to use code in the after update of the previous combo box and check the ListCount property to see if it should be visible or not.

Duane
Hook'D on Access
MS Access MVP
 
dhookom, thank you. These are not cascading they are based on individual queries. But I will definitely look into using cascading combo boxes!
 
I have 3 comboboxes, each one uses its own separate query. The query's criteria is based on the higher level categories choice on the form. Does this make sense? I'm not sure if I am really being clear here or not. Thanks again for the help.
 
How are ya ptrifile . . .

You say:
ptrifile said:
[blue] ... when the Main category is chosen the second category is visible and [purple]third when a second category is chosen[/purple].[/blue]
Looks like the 3rd combo is dependent on the second ... then you say:

ptrifile said:
[blue]The third Category choices are [purple]always dependent on what is chosen in the first two fields[/purple].[/blue]

See the confusion?

[blue]Your Thoughts . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
TheAceMan1, I do see the confusion....I think. All i am doing is loading the form with the visible property of the second and third category set to false. When the Main (or first) category's cbobox is changed the visible property for the second category is set to visible and then the same for the third when the value of the second category changes.

So my query for the third combobox is the following:

Code:
SELECT TblThirdCat.ThirdCat, TblThirdCat.SubCat, TblThirdCat.MainCat
FROM TblThirdCat
WHERE (((TblThirdCat.SubCat)=[forms]![frmmain]![second_category]) AND ((TblThirdCat.MainCat)=[forms]![frmmain]![main_category]));

On the OnChange event on the second category I am requerying the third category so the correct items come up....am i cascading comboboxes without realizing? I am just going about this entirely the wrong way?

Its not a huge deal if I can't do what I am asking, it works now as desired but would just be a little more user friendly the other way.

Thanks again for any help, suggestions or beatings.

Paul
 
ptrifile,
If you showed your code and row source, it would be much more clear and descriptive.
However you are requerying, you could add code to set the dependent combo box to visible if the ListCount > 0.

Duane
Hook'D on Access
MS Access MVP
 
dhookom,
Perfect! Exactly what i was looking for! Thanks for the help!

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top