Results 1 to 2 of 2
  1. #1
    Join Date
    May 2002
    Posts
    395

    Unanswered: syntax error(missing operator)

    I have a syntax error on my SQL statement using the BETWEEN… AND operator. It stated as follow:
    Syntax error(missing operator) in query expression ‘qryRGAqtr![Date] Between 2Q 2000 And 2Q 2001’.

    ‘This sub procedure calls the SQL statement to create a temp query

    Private Sub CreateChart()
    'Select the date range from the qryRGAqtr

    Dim sqtr As String
    Dim syr As String
    Dim startdate As String
    Dim eqtr As String
    Dim eyr As String
    Dim enddate As String
    Dim DB As Database
    Dim qcht As QueryDef
    Dim stDocName As String
    sqtr = cboSQtr
    syr = cboSYear
    eqtr = cboEQtr
    eyr = cboEYear

    startdate = sqtr & " " & syr
    enddate = eqtr & " " & eyr
    Debug.Print startdate, enddate

    Set DB = CurrentDb()
    'DB.QueryDefs.Delete ("qrytempqtr")

    sqlstate = "SELECT qryRGAqtr![Date],qryRGAqtr![Apple],qryRGAqtr![Other],"
    sqlstate = sqlstate & "qryRGAqtr![Apple %],qryRGAqtr![Other %] FROM qryRGAqtr"
    sqlstate = sqlstate & " WHERE qryRGAqtr![Date] Between " + startdate + " And "
    sqlstate = sqlstate & "" + enddate + ";"


    stDocName = "Form2"
    Set qcht = DB.CreateQueryDef("qrytempqtr", sqlstate)
    'qcht.SQL = sqlstate


    'DoCmd.OpenForm stDocName, , , sqlstate

    End Sub

    Thanks!!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the problem is here ---> Between 2Q 2000 And 2Q 2001

    you need to put those into legitimate date formats


    rudy

Posting Permissions

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