J
jlguitar287
Problem: I press the button to query, it goes to the correct form and filter
everything, but i go back to the form (without closing the Query), selec
something new from my list box, but it just stays the same as the firs
query..
Note: DoCmd.Requery doesn't wor
It should be super simple to understand
Option Compare Databas
Private Sub btnRun_Click(
Dim db As DAO.Databas
Dim qdf As DAO.QueryDe
Dim varItem As Varian
Dim strCriteria As Strin
Dim strSQL As Strin
Set db = CurrentDb(
Set qdf = db.QueryDefs("Query"
For Each varItem In Me!listBox.ItemsSelecte
strCriteria = strCriteria & "," & Me!listBox.ItemData(varItem
& "
Next varIte
If Len(strCriteria) = 0 The
MsgBox "You did not select anything."
, vbExclamation, "Nothing to find!
Exit Su
End I
strCriteria = Right(strCriteria, Len(strCriteria) - 1
strSQL = "SELECT * FROM TestTable " &
"WHERE TestTable.Field1 IN(" & strCriteria & ");
strSQL = "SELECT * FROM TestTable Where TestTable.Field1 Lik
""" & strCriteria & """;
qdf.SQL = strSQ
MsgBox strSQ
DoCmd.OpenQuery "Query
Me.RecordSource = "Query
'i press the button to query, it goes to the correct form and filter
'everything, but i go back to the form, select something new from 'my list box
but it just stays the same as the first query..
Set db = Nothin
qdf.Clos
Set qdf = Nothin
'Please Help!
everything, but i go back to the form (without closing the Query), selec
something new from my list box, but it just stays the same as the firs
query..
Note: DoCmd.Requery doesn't wor
It should be super simple to understand
Option Compare Databas
Private Sub btnRun_Click(
Dim db As DAO.Databas
Dim qdf As DAO.QueryDe
Dim varItem As Varian
Dim strCriteria As Strin
Dim strSQL As Strin
Set db = CurrentDb(
Set qdf = db.QueryDefs("Query"
For Each varItem In Me!listBox.ItemsSelecte
strCriteria = strCriteria & "," & Me!listBox.ItemData(varItem
& "
Next varIte
If Len(strCriteria) = 0 The
MsgBox "You did not select anything."
, vbExclamation, "Nothing to find!
Exit Su
End I
strCriteria = Right(strCriteria, Len(strCriteria) - 1
strSQL = "SELECT * FROM TestTable " &
"WHERE TestTable.Field1 IN(" & strCriteria & ");
strSQL = "SELECT * FROM TestTable Where TestTable.Field1 Lik
""" & strCriteria & """;
qdf.SQL = strSQ
MsgBox strSQ
DoCmd.OpenQuery "Query
Me.RecordSource = "Query
'i press the button to query, it goes to the correct form and filter
'everything, but i go back to the form, select something new from 'my list box
but it just stays the same as the first query..
Set db = Nothin
qdf.Clos
Set qdf = Nothin
'Please Help!