D
david
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)
Else
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.
Thanks
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)
Else
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.
Thanks