Populating Combo Boxes - why doesn't this work all the time?

amorts

Board Regular
Joined
Jan 4, 2006
Messages
181
I am using the following code to populate some of my combo boxes;

Private Sub form_Open(Cancel As Integer)
With combFilter
.RowSourceType = "Table/Query"
.RowSource = "<Name of Query>"
End With
End Sub

I find that this is quite tempermental. If works for some on some but not on others. I have ran the query and checked it produces the desired results. However, when I drop down the box in run time it is blank.

Any ideas?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
You show .RowSource = "". That is not a query. and therefore nothing would ever show up in your combo box.
 
Upvote 0
Sorry I forgot the tags on here would have taken that out.

I actually typed .RowSource= "qryName" but I put optional brackets around it originally!
 
Upvote 0
Could you post the SQL for the query? If it works by itself, but not for the combo box, the SQL would be a help to understand what is going on.

Something else to look at is the properties of the combo box. How many columns do you have defined, and which of these columns do you have set to a width of zero, for non-display of that column?
 
Upvote 0
Is qryName the actual name of the query?

Or is it a variable holding the name of the query?
 
Upvote 0
It's really strange I have just deleted and recreated the combo box and done the same with the query and it has now decided to work.

I had this same problem yesterday too!

Thanks for your help though guys.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top