Run Time Error 3075

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ledo
    New Member
    • Aug 2008
    • 3

    Run Time Error 3075

    I have a form that I want to show invoices in a date range. When clicking on the button I get the following error:

    Run Time Error 3075 Syntax error (missing operator) in query expression '(Invoice Date Between #08/27/2008 And #08/27/2008#)'

    Here is the code associated w/the error:

    Dim strReport As String 'Name of report to open.
    Dim strField As String 'Name of your date field.
    Dim strWhere As String 'Where condition for OpenReport.
    Const conDateFormat = "\#mm\/dd\/yyyy\#"

    strReport = "SDInvoice"
    strField = "Invoice Date"

    If IsNull(Me.txtSt artDate) Then
    If Not IsNull(Me.txtEn dDate) Then 'End date, but no start.
    strWhere = strField & " <= " & Format(Me.txtEn dDate, conDateFormat)
    End If
    Else
    If IsNull(Me.txtEn dDate) Then 'Start date, but no End.
    strWhere = strField & " >= " & Format(Me.txtSt artDate, conDateFormat)
    Else 'Both start and end dates.
    strWhere = strField & " Between " & Format(Me.txtSt artDate, conDateFormat) _
    & " And " & Format(Me.txtEn dDate, conDateFormat)
    End If
    End If

    ' Debug.Print strWhere 'For debugging purposes only.
    DoCmd.OpenRepor t strReport, acViewPreview, , strWhere

    What am I missing?
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    After building the Where Condition,
    Closing "#" for From date is missing..
    #08/27/2008 And #08/27/2008#

    Keep a BreakPoint at the beginning and check..

    REgards
    Veena

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #3
      Hi,

      I guess, there is one more problem...

      Your field name is "Invoice Date"
      there is a Space in the field name, so you need to Enclose Between
      SQUARE BRACKETS

      [code=oracle]
      "Select * From MyTable Where [Invoice Date] Between #08-08-2008# And #08-08-2008#"
      [/code]

      Regards
      Veena

      Comment

      • Ledo
        New Member
        • Aug 2008
        • 3

        #4
        Thanks for you reply. I have reworked the strWhere condition but now receive a "Run-time error 2427. You have entered an expression that has no value" and moves to the VBA code I have set in the "SDInvoice" report, and cannot figure out why? Any insight would appreciated.

        Comment

        • rpicilli
          New Member
          • Aug 2008
          • 77

          #5
          Helo,

          I think your problem is the Text mising in the text component.

          strWhere = strField & " Between " & Format(Me.txtSt artDate, conDateFormat) _
          & " And " & Format(Me.txtEn dDate, conDateFormat)


          If Me.txtSTartDate is refered to a textbox you need to add .Text like this

          me.txtStartDate .Text and the same at me.txtEndDate.T ext

          I hope this help

          Comment

          • Ledo
            New Member
            • Aug 2008
            • 3

            #6
            That did it, thanks to everyone for all your help!

            Comment

            Working...