Printing with Print Preview (1 Viewer)

Lkwdmntr

Registered User.
Local time
Yesterday, 16:39
Joined
Jul 10, 2019
Messages
277
Hello again,

Ok so, you know when you print most things you get a print preview with the option to print from another printer and other options like the number of copies and an actual print button?

This is what I would like to happen when I press a button in my form to print a report. Can anyone direct me on how to get this to happen? I am able to have a set a macro to either print or print preview, but can't figure how to get this all in one view.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:39
Joined
Feb 19, 2002
Messages
43,233
I don't like automatic printing. I generally create an option group on my forms that run reports. The option group includes Print, Preview, PDF, and sometimes Export the data to Excel. The user chooses the option and then presses the "print" button. The default is set to preview.
 

Lkwdmntr

Registered User.
Local time
Yesterday, 16:39
Joined
Jul 10, 2019
Messages
277
Thanks June7,
That is almost what I need, but not perfect. The option box to select the printer is there and, yes it does give the option to pick the copies. What it is not doing, is showing the print preview and then give the option to print from the preview.
I'm sure you have seen this before, where the preview is on the right side of the screen and the print options are on the left. This should be an easy option in access.
 

Micron

AWF VIP
Local time
Yesterday, 19:39
Joined
Oct 20, 2018
Messages
3,478
I am able to have a set a macro to either print or print preview, but can't figure how to get this all in one view.
What I think this means is being able to open a report, view it then get a print dialog when you go to print it.

I think to get both a preview and a print dialog you'll have to put a button on the report (set to view on screen only) and for its click event have Docmd.RunCommand.Print. Your process should open the report in report view or else the button won't show (IIRC), but it will look different from print preview.

EDIT - forgot to mention that you probably want to trap the error that will arise if the user clicks to cancel printing in the dialog.
 
Last edited:

June7

AWF VIP
Local time
Yesterday, 15:39
Joined
Mar 9, 2014
Messages
5,466
You mean like print preview as in Word or Excel? No, Access does not have that.

Your print preview is the open report behind printer dialog.
 

isladogs

MVP / VIP
Local time
Today, 00:39
Joined
Jan 14, 2017
Messages
18,209
Am I missing something here?
If you open a report using acViewPreview, the Print Preview ribbon appears with all the options you may require including page layout, multipage view, print to PDF/Excel and the standard Print dialog (select printer, number of copies).
 

June7

AWF VIP
Local time
Yesterday, 15:39
Joined
Mar 9, 2014
Messages
5,466
@Micron, do a print preview in Word and you will see what OP describes.

As Micron points out, in Access print operations are on ribbon, including a button for opening printer driver dialog.
 

Micron

AWF VIP
Local time
Yesterday, 19:39
Joined
Oct 20, 2018
Messages
3,478
@Micron, do a print preview in Word and you will see what OP describes.

As Micron points out, in Access print operations are on ribbon, including a button for opening printer driver dialog.
I don't get your point. I know what a print preview in Word looks like. You are saying that's the exact look that OP wants? I do know that what I proposed works - at least insofar as I interpreted the post, which is to preview the report and have a print dialog open when the report is still in view. BTW, it wasn't me who mentioned the ribbon, which is probably the right approach.
 

Lkwdmntr

Registered User.
Local time
Yesterday, 16:39
Joined
Jul 10, 2019
Messages
277
My print preview has no ribbon. Is there an option that I'm missing here? That would be great if I could get that to happen.

My goal is to have the exact same thing happen in access that happens in word when you go to print something.

I think there is an option that is not checked somewhere or I'm missing something in the settings maybe.
 

isladogs

MVP / VIP
Local time
Today, 00:39
Joined
Jan 14, 2017
Messages
18,209
Unless you have hidden the ribbon, the preview ribbon below should appear automatically when you open a report using acViewPreview or by selecting the report with that option



Note that it doesn't appear in the default report view, layout view or design view
 

Attachments

  • previewribbon.PNG
    previewribbon.PNG
    39.1 KB · Views: 255

Micron

AWF VIP
Local time
Yesterday, 19:39
Joined
Oct 20, 2018
Messages
3,478
this is what I was alluding to, although I admit I was looking at the forest and not seeing the trees. The ribbon seems to be the obvious choice - unless for some reason you need to open the report in report view. Then what I suggested may be an option.
 

Attachments

  • PrintDialog2.jpg
    PrintDialog2.jpg
    46.3 KB · Views: 245
Last edited:

Lkwdmntr

Registered User.
Local time
Yesterday, 16:39
Joined
Jul 10, 2019
Messages
277
Ok, I think I know what the problem is. My database is designed entirely of forms and reports that are in the pop-out and modal. When the report is a full screen, no ribbon shows. I was hoping to find a workaround and simply have the options shown on the left of the page as they do in Word.
 

Lkwdmntr

Registered User.
Local time
Yesterday, 16:39
Joined
Jul 10, 2019
Messages
277
Was hoping for something more like this.
Attached jpg
 

Attachments

  • doc.jpg
    doc.jpg
    93.5 KB · Views: 93

isladogs

MVP / VIP
Local time
Today, 00:39
Joined
Jan 14, 2017
Messages
18,209
Ok, I think I know what the problem is. My database is designed entirely of forms and reports that are in the pop-out and modal. When the report is a full screen, no ribbon shows. I was hoping to find a workaround and simply have the options shown on the left of the page as they do in Word.

The obvious question is why are you using modal reports? Or indeed forms?
Doing this for all items is both unnecessary and counter productive.
If you close or hide the calling form when you open the report you can set both popup and modal false. You will then see the preview ribbon if opened in that mode.
The Print button on the preview ribbon displays the standard dialog box
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:39
Joined
Feb 19, 2002
Messages
43,233
I don't like the tab view so I always use "Overlapping Windows". I also think that most of the time, having multiple windows open just confuses users so whenever form a opens form b, form a passes its name to form b in the OpenArgs and hides hides itself
Code:
DoCmd.OpenForm "formname", , , "wherecondition if necessary", , , Me.Name
Me.Visible = False
Then in the close event of form b, check the openargs and reopen that form
Code:
    If IsNull(me.OpenArgs) Then
        DoCmd.OpenForm "Switchboard"
    Else
        DoCmd.OpenForm me.OpenArgs
    End If

And since I hate having to write this code in every close event, I actually make common procedures and call them.
Code:
Call CommonClose
Here's my real close event. It's a little more complicated because it handles another important situation which is preventing forms from closing if there are pending save errors but that's for a different thread.
Code:
    Public Sub CommonClose(frm As Form)
On Error GoTo ErrProc
    If bForceClose = True Then
        Exit Sub        'do not run close code
    End If
    If frm.Dirty Then
        DoCmd.RunCommand acCmdSaveRecord
    End If
    If IsNull(frm.OpenArgs) Then
        DoCmd.OpenForm "Switchboard"
    Else
        DoCmd.OpenForm frm.OpenArgs
    End If
    
    bForceClose = False     'reset variable
ExitProc:
    Exit Sub
ErrProc:
    Select Case Err.Number
        Case 2102   'bad open args form name
            Resume ExitProc
        Case 2455   'happens for A2007 when unbound form references the Dirty property
            Resume Next
        Case Else
            MsgBox Err.Number & "--" & Err.Description
            Resume ExitProc
    End Select
End Sub
 

Lkwdmntr

Registered User.
Local time
Yesterday, 16:39
Joined
Jul 10, 2019
Messages
277
The person that is going to be using this know absolutely nothing about access and doesn't want to see any of the access interface. It is strictly form-based and everything is full screen. There is an enter button that takes you into the program and another button that will take you out completely. This is the way the boss wants it.
 

isladogs

MVP / VIP
Local time
Today, 00:39
Joined
Jan 14, 2017
Messages
18,209
So all your forms will be full screen but you can still use overlapping windows layout.
It also doesn't answer the question I asked.
Why are you using modal, popup forms and reports?
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:39
Joined
Feb 19, 2002
Messages
43,233
The person that is going to be using this know absolutely nothing about access and doesn't want to see any of the access interface. It is strictly form-based and everything is full screen. There is an enter button that takes you into the program and another button that will take you out completely. This is the way the boss wants it.
Nothing I said conflicts with your requirements. I simply told YOU how to accomplish it without using model forms which are more annoying than useful except in rare cases.
 

Users who are viewing this thread

Top Bottom