Changing a combo box's record source?

NewShoes

Registered User.
Local time
Today, 15:12
Joined
Aug 1, 2009
Messages
223
Hey all,

I'm basically trying to change a combo box's record source based on another combo box. However, to make matters a little more complicated (at least for me!), depending on what is slected in the first combo box, the number of columns in the second combo box will change. They will therefore also need to change widths.

Please can anyone offer any advice?!
Many thanks,
-NS
 
try it just by changing the recordsource

mycombobox.recordsource = "somequery"
mycombobox.requery

it doesnt matter about having extra columns really. i would try without worrying about the column widths, unless it becomes an issue.

even so, i presume you can just do something like this. not sure exactly what the properties are without looking into it

mycombobox.columncount = whatever
mycombobox.columnwidths = whatever
 
Thanks for the reply Dave. I just have a couple more questions...

Would this method be used as part of an IF statement?

By "somequery", would this just be the name of the pre-made Access query or would it be an SQL statement?

Many thanks!
-NS
 
the name of the query.

not sure what you mean by the if comment, though.
 
The sample here may give you some pointers. Have a look at the On Lost Focus event of Combo0.
 
not sure what you mean by the if comment, though.

Sorry, I meant do I need to use an IF to check what has been slected in the first combo box. For example...

IF ComboA = "Region 1" Then recordsource = "area1qry"
ElseIf ComboA = "Region 2" Then recordsource = "area2qry"

..and so on.

Thanks,
-NS
 
Are you really changing the Recordsource, or do you have 2 comboboxes and when you select an entry in the first, you want to change the selectable values in the second combobox?

If his is your situation, this is called cascading combos.
There is a great free video tutorial here.
http://www.datapigtechnologies.com/flashfiles/combobox2.html
 
Are you really changing the Recordsource, or do you have 2 comboboxes and when you select an entry in the first, you want to change the selectable values in the second combobox?

If his is your situation, this is called cascading combos.
There is a great free video tutorial here.
http://www.datapigtechnologies.com/flashfiles/combobox2.html

Humm, I'm unsure now. I basically need what you have just described but depending on what is chosen in the first combobox, the second combobox will need to display different columns (if that makes sense!).

Thanks,
-NS
 
Just realised that I've been mistakenly saying "Record Source" when what I meant was "Row Source".

Thanks,
-NS
 

Users who are viewing this thread

Back
Top Bottom