Results 1 to 8 of 8
  1. #1
    stupesek is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    46

    Where clause syntax

    What is my syntax problem in this statement?



    DoCmd.OpenReport strDocName, acViewPreview, ,[ReportNumber] Between [forms]![Get Print Batch]![BegReport] And [forms]![Get Print Batch]![EndReport]

    Thanks again

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    See if this helps:

    BaldyWeb wherecondition
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    stupesek is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    46
    I have now changed the statement to:

    DoCmd.OpenReport strDocName, acViewPreview, , "ReportNumber Between" & Me.[Forms]![Get Print Batch]![BegReport] & "And" & Me.[Forms]![Get Print Batch]![EndReport]

    And get "Microsoft Office cannot find the field '|' referenced in your expression."

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Your string will evaluate to:

    ReportNumber Between123And456

    See where you need to add some spaces? Also, you either use "Me" or the full form reference, not both.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    stupesek is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    46
    I am a bit limited on when to use what syntax.

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    DoCmd.OpenReport strDocName, acViewPreview, , "ReportNumber Between " & [Forms]![Get Print Batch]![BegReport] & " And " & [Forms]![Get Print Batch]![EndReport]
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    stupesek is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    46
    Bingo!! Thanks!! I didn't realize the spaces were that important...

  8. #8
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help. How is Access to know where one thing ends and the next begins without spaces? You and I can look at it and intuitively know, but Access can't. The error you got was Access's way of throwing up it's hands and saying "I don't understand!"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Use of COLLATE statement in SELECT clause
    By zurek in forum Queries
    Replies: 7
    Last Post: 03-16-2011, 06:46 AM
  2. update in where clause
    By mikensu in forum Access
    Replies: 0
    Last Post: 03-16-2009, 07:19 AM
  3. FROM Clause error message
    By skylite in forum Queries
    Replies: 2
    Last Post: 10-23-2008, 05:47 AM
  4. IIF clause
    By Peljo in forum Queries
    Replies: 2
    Last Post: 02-05-2008, 11:22 AM
  5. Help on WHERE clause
    By QBCM in forum Programming
    Replies: 1
    Last Post: 12-19-2005, 08:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums