Results 1 to 4 of 4
  1. #1
    Budatlitho is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2016
    Posts
    36

    Passing values to report giving between values

    Hello!
    I have an Access report titled JobTicket1Auto that in the query had Between [BeginningOrder] And [EndingOrder] as criteria which prompts the user to enter a value for BeginningOrder and EndingOrder. Works fine.

    I want to automate this report and have tried the following:


    Code:
    strSql = "SELECT * FROM Orders WHERE OrderId BETWEEN " & [First] & " and " & [Last]
    Debug.Print strSql
    '(in the immediate window appears SELECT * FROM Orders WHERE OrderId BETWEEN 6474 and 6475)
    
    DoCmd.OpenReport ReportName:="JobTicket1Auto", View:=acViewReport, WhereCondition:=strSql
    DoCmd.PrintOut
    DoCmd.Close
    Here's the error window text:
    Run-time error '3075:
    Syntax error in query expression 'SELECT * From Orders WHERE OrderId BETWEEN 6475 and 6476'.

    What is the syntax error?

    THANKS in advance!

    Bud

  2. #2
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Try it without the select part:
    Code:
    strSql = "OrderId BETWEEN " & [First] & " and " & [Last]
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    Budatlitho is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2016
    Posts
    36
    That worked! Thanks a lot.

  4. #4
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 4
    Last Post: 01-25-2019, 05:08 AM
  2. Replies: 4
    Last Post: 11-21-2018, 04:06 PM
  3. Replies: 3
    Last Post: 10-30-2016, 05:50 AM
  4. Passing values to a report from a form in Access 2013
    By InspectorHound in forum Reports
    Replies: 1
    Last Post: 06-17-2015, 02:58 PM
  5. Passing Multiple selection values to a report
    By techexpressinc in forum Forms
    Replies: 7
    Last Post: 01-13-2012, 02:27 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