Results 1 to 5 of 5
  1. #1
    namu23 is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    17

    VBA - reopen main form after closing the print preview

    Hello,

    I have a form named "Order Request Menu" with a command button that prints the current record that appears on the Order Request Menu form. The vba code i've put on the button (Print Record) is:



    Code:
    Private Sub Command55_Click()
    
    
    Me.Visible = False
    
    
    DoCmd.OpenReport "Print Order Request", acViewPreview, , "[ID] = Forms![Order Request Menu]![ID]"
    
    
    
    
    End Sub
    What the code from above does is when i clicked the Print Record, it will print preview the current record and hides the main form. Now, my problem is how can i reopen my main form after i close the print preview?

    Any help or suggestion to revise my code will be much appreciated

    Thank you.

    * Sorry, this post has been edited as i forgot to mentioned that the Order Request Form is POP UP and MODAL.
    Last edited by namu23; 01-05-2015 at 11:47 PM. Reason: Form is a popup modal

  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,652
    Make the form visible in the close event of the report.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    namu23 is offline Novice
    Windows 7 Access 2013
    Join Date
    Nov 2010
    Posts
    17
    Thanks pbaldy, yes that is what i'm trying to do but i don't know how to do it. Can you please guide me how to trigger the close event on the report?

    And here's what i did:

    On the acViewReport, i can put a close button to reopen the form and close the report. But on the acViewPreview, the button will be gone and there is no way i can go back to the form unless i reopen it manually. I want to apply this on the acViewPreview and not going back to acViewReport to close the report and reopen the form automatically

  4. #4
    namu23 is offline Novice
    Windows 7 Access 2013
    Join Date
    Nov 2010
    Posts
    17
    Done!

    i need to add this code WindowMode :=acDialog before the me.visible = true

    Code:
    Private Sub Label56_DblClick(Cancel As Integer)
    
    Me.Visible = False
    DoCmd.OpenReport "Print Order Request", acViewPreview, , "[ID] = Forms![Order Request Menu]![ID]", WindowMode:=acDialog
    Me.Visible = True
    
    
    End Sub

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Glad you got it sorted. The close event would have been triggered by the user closing the report in preview mode. You didn't need a button.
    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. Replies: 5
    Last Post: 07-29-2014, 01:05 PM
  2. Automatically Closing Print Preview Window
    By chris.williams in forum Reports
    Replies: 5
    Last Post: 08-07-2012, 05:02 PM
  3. Form in Print Preview
    By dennisjoven in forum Forms
    Replies: 2
    Last Post: 08-11-2011, 09:19 AM
  4. Preview print on form ???
    By rfhall50 in forum Forms
    Replies: 0
    Last Post: 03-28-2011, 10:16 AM
  5. Form print preview problem
    By kloss1a in forum Forms
    Replies: 3
    Last Post: 01-03-2011, 12:12 AM

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