Combo box in a query

Blueskies

Registered User.
Local time
Today, 11:54
Joined
Oct 23, 2009
Messages
69
Hi there

I can create a select query with a combo box in it by changing the property of one of the fields - making the display control to combo box and adding the values. No problem there.

What I want to do is to be able to create a query dynamically from vba using a CreateQueryDef statement.

The problem is that you can only pass an SQL string to CreateQueryDef, and the combo box values are not part of the SQL code, but are saved with the query (presumably the same way column layout gets saved).

Is there a way to create a query with VBA and include non-SQL layout criteria so I can have combo boxes?

I'm using Access 2002 (yes, I know I need to upgrade!)

Thanks!
 
Either I am not able to follow you, or you are not explaining the issue very well... Could you give another shot at explaining what is that you are trying to do?
 
I'm a couple of posts short of being able to post graphics - here's one to make up the numbers.
 
And here's another. Hopefully next one will let me add pics.
 
OK, here's the query showing a drop-down box:

attachment.php



I create this combo box my modifying the field property in the query as follows:

attachment.php


SQL for this is just:

SELECT Table1.f3 FROM Table1;

As you can see the SQL does not contain any reference to the drop-down - this is saved with the query layout I imagine. Therefore when I create a query from VBA using createquerydef, I can't include the combo box.

The question is: is there a way to create a query in VBA and control elements other than just the SQL itself - eg the column widths. If there is, I expect this is how I can create the combo box as well :)

Cheers
 

Attachments

  • drop down.jpg
    drop down.jpg
    17.5 KB · Views: 214
  • choices.jpg
    choices.jpg
    24 KB · Views: 197
Change the Row Source Type to Table/Query.
But (maybe is a bug, maybe not) my Access 2007 do not allow a query as Row Source. I was able to select here only the tables.
 
I can change the row source, but the main issue is how to do all of this through VBA - I can create the query using Createquerydef but I need to know how to put the combo box in, which does not appear to be possible with createquerydef.
 

Users who are viewing this thread

Back
Top Bottom