I have a Continuous Form that has two combo boxes. If I don't link them together all values appear but if I link the two combo boxes to make one of them depend on other for easier choose from, the values never show in the second combo. I try to make code with if condition in vba to requery the combo values to show in all records but I couldn't. How could I do that? Thank you for all what you do
CodePudding user response:
This technique is known as cascading combobox. A very common topic. Be aware that if combobox RowSource uses an alias (displays text when saving ID) the text will not be available for display in all records when the list is filtered. This is especially disconcerting for users of continuous/datasheet view form.
Could have code that only filters second combobox when it gets focus then restore the full list when loses focus. Users will still see data briefly disappear from other records and may find distracting at first but will learn to disregard.
However, a workaround to maintain display of text is to include the combobox RowSource lookup table in a query used as form RecordSource. Bind a textbox to the descriptive text field from lookup table. Set textbox as Locked Yes and TabStop No. In continuous view, can size and position textbox on top of combobox to obscure combobox text but still show drop arrow (a "hybrid" control). In datasheet view the textbox will not be superimposed but text will be displayed.
If controls are superimposed, users accustomed to clicking into combobox text frame and typing input will encounter aggravation as the textbox will likely be the control they click. Tabbing to the combobox or clicking drop arrow will cause combobox to get focus and display over the textbox.