Results 1 to 3 of 3
  1. #1
    degras is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    72

    Pass argument to a report from VBA?

    I have a report that I run from a command button with the following VBA:

    DoCmd.OpenReport "Invoices", acViewPreview, , ""

    The report has a parameter / argument called [Invoice No]. Is it possible to pass in the parameter (based on the current record) or should I get rid of the parameter and use the reports where clause instead?

    Also I would like to go straight to printing report rather than going to a print preview screen.

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    If you are always going to open the report from the screen where the parameter is set then you don't need to worry about using the where clause.

    To go straight to print use acViewNormal

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Here's one way to restrict a report to a particular record:

    BaldyWeb wherecondition
    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. Pass Subform filter to subform in report
    By camftm in forum Programming
    Replies: 16
    Last Post: 07-19-2011, 07:12 AM
  2. Pass subform filter to a report
    By dinorbaccess in forum Reports
    Replies: 3
    Last Post: 01-10-2011, 05:34 PM
  3. Compile Error: Argument Not Optional
    By bg18461 in forum Access
    Replies: 1
    Last Post: 12-01-2010, 08:47 AM
  4. Replies: 2
    Last Post: 08-05-2010, 08:16 AM
  5. Invalid Argument Error
    By koper in forum Access
    Replies: 2
    Last Post: 06-14-2010, 11:22 AM

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