Results 1 to 2 of 2
  1. #1
    usmcgrunt's Avatar
    usmcgrunt is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2010
    Location
    Just outside the gates of freedom
    Posts
    71

    underlying form prints instead of report

    I have a database with a custom switchboard form with buttons that take the user to other forms. One of the underlying forms has a button that the user clicks to generate a report based on the forms current record.

    I have set the two forms up as 'popup' as well as the report. I have coded the main form to close when the next form opens.

    Now the code that I have on the form button to preview the report works perfectly. However, when the user attempts to print the report all that prints out is the main form, even if it is closed.

    My first attempt was Allen Bunch's (aka RuralGuy) code from

    http://allenbrowne.com/casu-15.html

    **********************************
    Private Sub btnPrintLC_Click()



    Dim strReport As String
    Dim strWhere As String

    If Me.Dirty Then
    Me.Dirty = False
    End If

    If Me.NewRecord Then
    MsgBox "Select a record to print"
    Else

    strReport = "rptLC"
    strWhere = "[LNumber] = """ & me!LNumber & """"

    DoCmd.OpenReport strDocName, acPreview, , strWhere

    End If
    End Sub
    ************************************
    this still resulted in the underlying form printing instead of the report.

    Then, after some more research I tried some code I found at

    http://thedailyreviewer.com/office/v...form-108129358

    ************************************
    Private Sub btnPrintLC_Click()

    Me.Visible = False

    Dim strReport As String
    Dim strWhere As String

    strReport = "rptLC"
    strWhere = "[LNumber] = """ & me!LNumber & """"

    Docmd.OpenReport strReport, acView Preview, , strWhere
    While sysCmd(acSysCmdGetObjectState, acReport, "rptLC") = acObjStateOpen

    DoEvents
    Wend

    Me.Visible = True
    End Sub
    ***************************************
    Again the same problem.

    Further research leads me to believe that I am having some sort of FOCUS problem with my report. It prints right if I

    1. Right click while my mouse is over the report and choose the print option.

    2. Print directly from the report with no underlying forms open.

    Unfortunately, neither of these options will work in the environment that I am developing this database for (i.e. users with zero knowledge of Microsoft Access). I know for a fact that they will default to the way they are used to printing documents and that is by the windows icon in the top left corner of the screen and then selecting print from there which will result in the report losing focus and the underling form printing.

    Looking forward to some more suggestions to keep this fire going.

    thanks, Sean

  2. #2
    usmcgrunt's Avatar
    usmcgrunt is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2010
    Location
    Just outside the gates of freedom
    Posts
    71
    After further review, my comments below still don't help me. The user is not able to preview the report for formatting accuracy becase the print dialog box is popup/modal so I cannot change the focus to the report to view it.

    ************************************************** ******************

    Ok, after some additional research I think I am on the right track now.

    I am now able to get the report to print with the addition of code to bring up the print dialog box. It looks something like this:

    DoCmd.OpenReport strReport, acViewPreview,, strWHERECondition
    RunCommand acCmdPrint

    However I think I need some sort of delay code between these two lines because when I click the print button on the form, the report preview opens up blank and the print dialog box immediately opens. The report prints fine but the screen does not display the report. I am assuming that since I am filtering the report, the system does not have enough time to filter the report before displaying the print dialog.

    Suggestions?

    Thanks, Sean
    Last edited by usmcgrunt; 09-17-2010 at 05:40 AM. Reason: Still not what I was looking for

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

Similar Threads

  1. only prints the same query - no matter what i have open
    By RedGoneWILD in forum Programming
    Replies: 9
    Last Post: 08-31-2010, 10:47 AM
  2. Replies: 2
    Last Post: 08-26-2009, 10:43 AM
  3. Replies: 1
    Last Post: 03-02-2009, 11:54 AM
  4. Report Prints Out Before Previewing
    By Schwagr in forum Reports
    Replies: 2
    Last Post: 03-18-2006, 02:15 PM
  5. report prints blank page at end of report
    By darrellx in forum Forms
    Replies: 0
    Last Post: 03-14-2006, 08:51 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