Results 1 to 2 of 2
  1. #1
    carrybag93 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    7

    Help with VBA

    This is the code:

    DoCmd.RunCommand acCmdSaveRecord


    DoCmd.OpenReport "ReportName", acNormal, , "([OrderID])=" & Me.[OrderID]

    I put this on the print button in my form. What I want to happen is for a report to generate as a result of pressing the button. I do not necessarily want it to print, but that is what someone else told me to do. So on the print button, in the property sheet on the OnClick is the code above. Is that where I am supposed to put the code? Also, what do I need to change about it? When I pressed the button in Form View, an error message came up. I have attached the screenshot. Click image for larger version. 

Name:	error.jpg 
Views:	11 
Size:	92.1 KB 
ID:	7908 What do I need to change in the code to get this to work? The overall result I would like is that the user fills out the order form, and at the bottom of the form is a button that says 'Generate Receipt', and a new report creates itself with all of the data given on the order form. There are buttons on this receipt to save, print, email and return to the other form.

    Is this the right code for the job?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Tags for this Thread

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