using "list box" to pass parameter to a query

letsomebodyknow

New member
Local time
Yesterday, 18:25
Joined
Nov 16, 2006
Messages
7
:) I like to learn Access. This forum has helped. I would like to pass a value from a "list Box" as a parameter for a query. Is there a way to do this or will I have to do some coding to set the passing of the control.

I would prefer to pass it and use the creteria options which opens a window. I have not see this option as of yet....


Thanks
Tom:)



The text below is copied from the help offored with the program on my desktop. Its clear but I need more info and steps
********************************************************

When a user selects a value in a list box, drop-down list box, or combo box, Microsoft Access can do one of two things: Access can store the selected value in a table (not the same table that the list gets its rows from), or Access can pass the value to another control. For example, for the Supplier list box in the preceding illustration, if a user selects "Pavlova, Ltd." , Access looks up the primary key value (SupplierID) for Pavlova, Ltd. in the Suppliers table and sets the SupplierID field (the foreign key) for the current record in the Products table to the same value. This is the value that is stored. Because Access is storing a value based on a selection in the list box, the list box is bound. (Note that the SupplierName value that comes from the Suppliers table is displayed in the list box but not stored.)
 
I did something like this a couple of years ago. In the modules section, create a module and call it Globals. Then at the top enter

Public VariableName As TypeOfVariable.

Then, under that type

Public Function ReadVariableName() As TypeOfVariable
ReadVariableName = VariableName
End Function

Then, in the BeforeUpdate event, enter

VariableName = Me!ListBoxSelection

Then, set your query criteria equal to the function.
 

Users who are viewing this thread

Back
Top Bottom