Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Expected End of Statement (2000)

    Hi!

    I'm using the following code to open a report and am getting an error stating "expected end of statement" - "balance" is highlighted. I'm not sure what is missing. The original code worked fine and read as follows:

    strWhere = "[Account Name] = '" & Me.List2.Column(1) & "'" & _
    " And ([Date] Between #" & Me.STARTDATE & "# And #" & Me.ENDDATE & "#) "
    DoCmd.OpenReport "rptUnpaidAR - Individual Account", acViewPreview, , strWhere

    I adapted the code to filter for balances <0 and that is when the problems started. Here is the problem code:

    strWhere = "[Account Name] = '" & Me.List2.Column(1) & "'" & _
    " And ([Date] Between #" & Me.STARTDATE & "# And #" & Me.ENDDATE & "#) and "balance>0") "
    DoCmd.OpenReport "rptUnpaidAR - Individual Account", acViewPreview, , strWhere

    Thanks,
    Leesha

  2. #2
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Expected End of Statement (2000)

    Leesha
    Try the following with double quotes

    strWhere = "[Account Name] = '" & Me.List2.Column(1) & "'" & _
    " And ([Date] Between #" & Me.STARTDATE & "# And #" & Me.ENDDATE & "#) and ""balance"">0) "
    DoCmd.OpenReport "rptUnpaidAR - Individual Account", acViewPreview, , strWhere

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Expected End of Statement (2000)

    If you keep careful track of the quotes and parentheses (it is confusing), you will see that the phrase Balance>0 has ended up outside the quotes and that the parenthesis at the end serves no purpose.

    strWhere = "[Account Name] = '" & Me.List2.Column(1) & "'" & _
    " And ([Date] Between #" & Me.STARTDATE & "# And #" & Me.ENDDATE & "#) and balance>0 "

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Expected End of Statement (2000)

    I should have seen that.
    I assumed it was a text value (enclosed in quotes)but Leesha is working with numeric and dates <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30>

  5. #5
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Expected End of Statement (2000)

    Thanks Hans and Dave for your help!!! I'm set to go again but am sure to be back. <img src=/S/compute.gif border=0 alt=compute width=40 height=20>

Posting Permissions

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