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

    Unanswered: syntax error(Missing Operator)

    I received a syntax error in my query, I can't see where the error(s) at.

    Run-time eror '3075'
    Syntax Error(Missing Operator) in query expression('qryRGAqtr!Date BETWEEN 3Q 1999 AND 3Q 2002)'.

    Here is my code:

    Private Sub MakeChart(ByVal Sdate As String, Edate As String)

    Dim qtr As Recordset
    Dim rst As Recordset
    Dim strSQL As String

    strSQL = "SELECT * FROM qryRGAqtr WHERE (qryRGAqtr!Date Between " + Sdate + " And " + Edate + ");"
    Set rst = CurrentDb.OpenRecordset(strSQL)

    Do Until rst.EOF
    Debug.Print rst!Date
    rst.MoveNext

    End Sub


    Thanks!

  2. #2
    Join Date
    Aug 2002
    Posts
    29

    Re: syntax error(Missing Operator)

    Private Sub MakeChart(ByVal Sdate As String, Edate As String)

    Dim qtr As Recordset
    Dim rst As Recordset
    Dim strSQL As String

    '-- Use the "#" only if the "Date" field is of the Date/Time datatype. --
    strSQL = "SELECT * FROM qryRGAqtr WHERE (Date Between #" & Sdate & "# And #" & Edate & "#);"
    Set rst = CurrentDb.OpenRecordset(strSQL)

    Do Until rst.EOF
    Debug.Print rst!Date
    rst.MoveNext
    Loop

    End Sub

    '----------------------------------------------------
    Also... for debugging stuff like this, put a "debug.print strSQL" statement right after the line where you set the strSQL variable. Then copy the query out of the debug window into a new query (in SQL view). Try running it.
    '----------------------------------------------------
    Last edited by GodMadeIncubus; 11-11-02 at 17:50.

Posting Permissions

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