Results 1 to 3 of 3

Thread: SQL in Access '97

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    24

    Question

    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



  2. #2
    Lively Member
    Join Date
    Jul 2000
    Location
    Stockholm, Sweden
    Posts
    83
    Is this that you are looking for ?

    strSQL = "Select Week,Year,LineYear from Used where [linecode] = '" & strFilterLine & "'"
    Yesterday, all my troubles seemed so far away...
    Help, I need somebody, Help...
    Now MCSD and still locking for intresting job in the south parts of Stockholm, Sweden.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    24
    AKA,

    Thanks. That works great.

    ern

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width