Alphacircuits
asked on
How to Pass (text) criteria to a query using a Multi List Box
Hello Experts,
Using Access 2K I am trying to use a multi list box in a Form to select one or many customers and pass the selection as criteria to a query.
I am hip to the fact that this has to be done in code since the selection has to be concatenated in order for Access to know what to do with it which leads to my question....How do I do this?
Current DB Info:
As is, the form (frmNetBookings) has two Date inputs which pass criteria to a query. Based on that date range the listbox (lbCustomerList) identifies the possible customers from said query. After this step, what I had in mind was to Select one or many customers from the listbox and then click a "Export" button that will export the query (qryNetBookings) to an excel file. All of this works except for the Multiple criteria from the listbox.
The current select staement in the listbox RowSource property is, SELECT [qry_NetBookings1].[Custom er_Name] FROM qry_NetBookings1 GROUP BY [qry_NetBookings1].[Custom er_Name] ORDER BY [qry_NetBookings1].[Custom er_Name];
Thanks,
nEwT
Using Access 2K I am trying to use a multi list box in a Form to select one or many customers and pass the selection as criteria to a query.
I am hip to the fact that this has to be done in code since the selection has to be concatenated in order for Access to know what to do with it which leads to my question....How do I do this?
Current DB Info:
As is, the form (frmNetBookings) has two Date inputs which pass criteria to a query. Based on that date range the listbox (lbCustomerList) identifies the possible customers from said query. After this step, what I had in mind was to Select one or many customers from the listbox and then click a "Export" button that will export the query (qryNetBookings) to an excel file. All of this works except for the Multiple criteria from the listbox.
The current select staement in the listbox RowSource property is, SELECT [qry_NetBookings1].[Custom
Thanks,
nEwT
Sorry -ignore that - I'm having some 'post too-early' problems this morning..
I'll post again in a minute.
I'll post again in a minute.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Good morning Peter57r, thanks for the reply. I have one additional questiion...Where do place this code? Would it be an after update in the listbox?
You could place the code into the exit event of the listbox - you would need to assign the the result to something though - maybe a hidden textbox on your form. (Obviously what you do with the string will affect your export query sql.)
If Not IsNull(varItem) Then
'Build up the filter from the bound column (hidden).
strWhere = strWhere & strDelim & .ItemData(varItem) & strDelim & ","
'Build up the description from the text in the visible column. See note 2.
strDescrip = strDescrip & """" & .Column(1, varItem) & """, "
End If
Next