PDA

Click to See Complete Forum and Search --> : SQL in Access '97


ernmeister
Sep 12th, 2000, 10:19 AM
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

AKA
Sep 12th, 2000, 10:44 AM
Is this that you are looking for ?

strSQL = "Select Week,Year,LineYear from Used where [linecode] = '" & strFilterLine & "'"

ernmeister
Sep 12th, 2000, 11:11 AM
AKA,

Thanks. That works great.

ern