query based on multiselctbox



Hi, i want to make an query based on a multiselctboxin a form. i have the
following code:

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String

Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiselect")

If Me!lstSagsnummer.ItemsSelected.Count > 0 Then
For Each varItem In Me!lstSagsnummer.ItemsSelected
strCriteria = strCriteria & "Sager_HT.Sagsnummer = " & Chr(34) _
& Me!lstSagsnummer.ItemData(varItem) & Chr(34) &
"OR "
Next varItem
strCriteria = Left(strCriteria, Len(strCriteria) - 3)
strCriteria = "Sager_HT.Sagsnummer Like '*'"
End If

strSQL = "SELECT * FROM Sager_HT " & _
"WHERE " & strCriteria & ";"
qdf.SQL = strSQL

But, i want to take some data from another table. hope anyone can help me.


Could you tell us what other table?
What are the fields you are looking to incorporate into this query?

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question