Combo Box Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I am working on a searchable database using a form as my interface. I want to have a combo box that contains the names of the queries that I want, not the values that are inside 1 particular query. I do not see a feature that allows me to do that with the wizard. I thought of typing the names of the queries into the combo box, but then how would I link those names to the names of the actual queries. Let me know if you can help, thank you very much

-Mat
 
Hi,

I am working on a searchable database using a form as my interface. I want to have a combo box that contains the names of the queries that I want, not the values that are inside 1 particular query. I do not see a feature that allows me to do that with the wizard. I thought of typing the names of the queries into the combo box, but then how would I link those names to the names of the actual queries. Let me know if you can help, thank you very much.

-Matt

If you want the names of all the queries:

Set the combo box Row Source Type property to Table/Query.
Set the Rowsource to:

SELECT MSysObjects.Name FROM MSysObjects WHERE
(((Left([Name],1))<>"~") AND ((MSysObjects.Type)=5)) ORDER BY
MSysObjects.Name;

Set the bound column to 1.
Set the ColumnWidths property to 1"
Set the LimitTo List to Yes.
Set the AutoExpand to Yes.

Then, if you wanted to run any one particular query, based upon it
being selected in this combo box, code the AfteUpdate event:
DoCmd.OpenQuery Me!ComboName
 
Fred

Thanks for your help, but I keep getting a Syntax Error on (((Left([Name],1))<>"~") AND ((MSysObjects.Type)=5)

is 'Name' a variable and I have to type in the names of my queries? Or am I missing something else.

Thanks again

----- fredg wrote: ----

On Sun, 30 May 2004 12:01:03 -0700, Matt wrote

If you want the names of all the queries

Set the combo box Row Source Type property to Table/Query
Set the Rowsource to

SELECT MSysObjects.Name FROM MSysObjects WHER
(((Left([Name],1))<>"~") AND ((MSysObjects.Type)=5)) ORDER B
MSysObjects.Name

Set the bound column to 1
Set the ColumnWidths property to 1
Set the LimitTo List to Yes
Set the AutoExpand to Yes

Then, if you wanted to run any one particular query, based upon i
being selected in this combo box, code the AfteUpdate event
DoCmd.OpenQuery Me!ComboNam
 
Fred,

Thanks for your help, but I keep getting a Syntax Error on
(((Left([Name],1))<>"~") AND ((MSysObjects.Type)=5))


is 'Name' a variable and I have to type in the names of my queries?
Or am I missing something else.

Thanks again!

----- fredg wrote: -----


If you want the names of all the queries:

Set the combo box Row Source Type property to Table/Query. Set the
Rowsource to:

SELECT MSysObjects.Name FROM MSysObjects WHERE
(((Left([Name],1))<>"~") AND ((MSysObjects.Type)=5)) ORDER BY
MSysObjects.Name;

Set the bound column to 1. Set the ColumnWidths property to 1" Set
the LimitTo List to Yes. Set the AutoExpand to Yes.

Then, if you wanted to run any one particular query, based upon it
being selected in this combo box, code the AfteUpdate event:
DoCmd.OpenQuery Me!ComboName

The Row Source Type must be set to Table/Query.
The Row Source SQL must all be on one line.

Click on the RowSource. Then click on the 3 dots button that appears
on that line.
Delete whatever is already in the Query grid.

Click on the Query View tool button and select SQL View.

Copy and paste the below SQL into the SQL window.

SELECT MSysObjects.Name FROM MSysObjects
WHERE (((Left([Name],1))<>"~") AND ((MSysObjects.Type)=5))
ORDER BY MSysObjects.Name;


MAKE SURE that any extra >'s used by your email reader to show quoted
text is not included in the SQL. (There is only one use of the >
symbol, and is in the <> "~" part of the code.)

Do NOT change Name. It is correct as shown.

If you still have an error it may be that you are missing a reference.
Open any module in Design view.
On the Tools menu, click References.
Click to clear the check box for the type library or object library
marked as "Missing:."

An alternative to removing the reference is to restore the referenced
file to the path specified in the References dialog box. If the
referenced file is in a new location, clear the "Missing:" reference
and create a new reference to the file in its new folder.

See Microsoft KnowledgeBase articles:
283115 'ACC2002: References That You Must Set When You Work with
Microsoft Access'
Or for Access 97:
175484 'References to Set When Working With Microsoft Access' for
the correct ones needed,
and
160870 'VBA Functions Break in Database with Missing References' for
how to reset a missing one.
 
Back
Top