Can I load a bound combo box from VBA ? (1 Viewer)

dcavaiani

Registered User.
Local time
Today, 03:45
Joined
May 26, 2014
Messages
385
Is there a way to load a bound combo box using IF statements in VBA? I am trying to load the combo box from a field from 2 different tables - depending on the value of a preceding field. Possible ??
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:45
Joined
Oct 29, 2018
Messages
21,358
Hi. Of course, you would just modify its Row Source property.
 

dcavaiani

Registered User.
Local time
Today, 03:45
Joined
May 26, 2014
Messages
385
Hi. Of course, you would just modify its Row Source property.

You make it sound so easy ..... Could I leave one source in the combo field definition and provide IF vba code to select the values from a different source ? Or, maybe it wud be simpler to hard code the "other" values in the VBA to avoid the SELECT issues?
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 01:45
Joined
Oct 29, 2018
Messages
21,358
You make it sound so easy ..... Could I leave one source in the combo field definition and provide IF vba code to select the values from a different source ? Or, maybe it wud be simpler to hard code the "other" values in the VBA to avoid the SELECT issues?
Hi. Yes, you can, but you'll probably end up doing both in VBA as well anyway depending on where/how the combobox is used.
 

dcavaiani

Registered User.
Local time
Today, 03:45
Joined
May 26, 2014
Messages
385
Thanks theDBguy - U gave me confidence and looks like I got it !!
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 19:45
Joined
Jan 20, 2009
Messages
12,849
Your description of having the RowSource come from two different tables suggests you have not normalized properly.

I expect you should have the RowSource records all in the one table with an extra field to select which of them is associated with the value in the "preceding field". The RowSource query simply refers to that control in the Where clause. A Requery of the combo is done in the Form OnCurrent and the "previous field's" Control AfterUpdate.
 

Users who are viewing this thread

Top Bottom