Variable in query criteria

Rakier

Registered User.
Local time
Today, 07:59
Joined
Mar 21, 2002
Messages
75
I'm hoping someone can help me with this.

The short question:

How can I pass a variable from a form to a query that is used to populate a list box on the form?

The long version:

I have a form...we'll call it frmAlpha. On the form there is a list box, lstItems. There is a text box called strItemText. When you type a value in the text box, it requeries the listbox to show items that begin with those letters.

The query "qryHSItems" has the following criteria for the strItemName field.

Like [forms]![frmAlpha].[strItemText] & "*"

There is also some code on the form for the OnChange event of the text box.

This works great, however I am needing to build more forms that will have other names and I want to use the same query for all of these forms. Each of the forms is for different functions, but each needs to access the same information from this query.

Is there a way to pass the name of the form to the querie's criteria? I can copy the query and make a new one, replacing the form name with the appropriate name, however, I want to make as few queries as possible. I can't seem to get it to work.
 
See Access Help for "property Procedures"

Briefly;
you make a module with Private variables,
in the module you make Public Property procedures to store and retrieve values in the variables,
you use the procedures in Forms and Queries.

HTH,
RichM
 

Users who are viewing this thread

Back
Top Bottom