Solved

printing a report based on information in a form that is on screen

Posted on 2012-04-03
2
310 Views
Last Modified: 2012-08-14
I have a form that i have created and at the top of the form i created a command button the user can press to print a report based on the information they have put in the form.  The field that I use as the control field is called Bill.  Once the form is filled out they press a button at the top labeled Print and they are supposed to see a print preview of a report that has the information they just typed into the form.  The form accepts all the information and the table retains all of the data but the report is blank.  Below is the code i am using for on click of the command button i created.

Private Sub Command156_Click()
On Error GoTo Err_Command156_Click
DoCmd.OpenReport "P1BOL", acViewPreview, , "[Bill]=" & Me.Bill
        Dim stDocName As String
        stDocName = "P1BOL"
        DoCmd.OpenReport stDocName, acPreview
       
Exit_Command156_Click:
Exit Sub

Err_Command156_Click:
 MsgBox Err.Description
 Resume Exit_Command156_Click

       
End Sub
0
Comment
Question by:AisinAuto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Assisted Solution

by:Dale Fye
Dale Fye earned 250 total points
ID: 37801190
You need to make sure that the current record is saved first.  Try:

Private Sub Command156_Click()

    On Error GoTo Err_Command156_Click

    me.Dirty = false
    DoCmd.OpenReport "P1BOL", acViewPreview, , "[Bill]=" & Me.Bill

Exit_Command156_Click:
    Exit Sub
Err_Command156_Click:
 MsgBox Err.Description
 
End Sub
0
 
LVL 77

Accepted Solution

by:
peter57r earned 250 total points
ID: 37801194
You need to be sure you have saved the current record before opening your report.

Add
Me.Dirty = False
at the start of your code.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question