Hi Peter,
Please don't start a second thread if it's still related to the first. It
makes finding the answer to your original question easier.
To get the second column of a list box use
YourForm!YourLi stBox.ItemData( varItems).Colum n(1)
Column(0) is the first column (which is the default), Column(1) is the
second column, Column(2) is the third column, etc.
Use the dynamic sql string to create a query. Add a few more lines to the
code I posted earlier to create a query for the recordsource for your form.
Dim db As DAO.Database
Dim qdfTemp As DAO.QueryDef
Set db = CurrentDB
*** The code posted earlier***
Set qdfTemp = db.CreateQueryD ef("YourQueryNa me", strSQL)
On Error Resume Next
Set qdf = Nothing
Set db = Nothing
Place all that code into the OnOpen event of your form.
You will need to write a good error trap routine to trap a zero record
recordset and if the query you're creating already exists.
In the OnClose event place this code
On Error Resume Next
DoCmd.DeleteObj ect acQuery, "Your Query Name"
Jeff
"Peter Bailey" <pe*********@an daluz.fsbusines s.co.uk> wrote in message
news:ch******** **@newsg2.svr.p ol.co.uk...
Could someone please tell me how to pass criteria as if it were a
parameter.
I have a routine now that creates the sql string (well almost). at present
the parameter is [Get DOS module] so I can pass one item ie Module M10S.
Want I want to do is send 1 or more parameters ie M10S OR M10SA OR ......
The query works with one parameter can I send the dynamic sql from vba as
a complete parameter string once the form calls the query?
also I notice the "air" code I have uses the hidden field of the list box
ie the PK is being returned can I get the descriptive text ie in my case
[Module description (text field)] "M10S" I couldnt see how to get the text
string from another column.
regards
Peter