-
I am trying to create a query using a variable (strFilterLIne) to set the filter. The program with create the query, however, in the SELECT statement it doesn't understand that strFilterLine is a variable equal to "FPT", it interprets it as a character string. Any ideas how I can get it to read strFilterLine as a variable?
Thanks,
Ern
Private Sub Command16_Click()
Dim dbs As Database, qdf As QueryDef, strSQL As String
Dim strFilterLine As String
Set dbs = CurrentDb
strFilterLine = "FPT"
DoCmd.DeleteObject acQuery, "Append to Used Temp(1)"
strSQL = "Select Week,Year,LineYear from Used where [linecode] = strFilterLine"
Set qdf = dbs.CreateQueryDef("Append to Used Temp(1)", strSQL)
Set dbs = Nothing
End Sub
-
Is this that you are looking for ?
strSQL = "Select Week,Year,LineYear from Used where [linecode] = '" & strFilterLine & "'"
-
AKA,
Thanks. That works great.
ern