Open a form while report is open in print preview (1 Viewer)

zeroaccess

Active member
Local time
Today, 07:52
Joined
Jan 30, 2020
Messages
631
Hi all,

I have a report that I must show in Print Preview as Report View does not display my subreports accurately. Unfortunately, Print Preview means my on-form command buttons disappear, so I have reluctantly enabled the right-click menu to print and send as attachment.

Two problems. One, I would really prefer to not allow shortcut menus at all. Two, Print Preview by default was way too small, so I opened it maximized.

Unfortunately, for some strange reason some of the shortcut menu items disappear (including send as attachment) when a report is opened maximized in print preview.

So my solution seems to be once again disabling shortcut menus and instead having a small popup form open in conjunction with the report, where I can place my own controls.

Unfortunately (there seems to be a catch to every solution) if I DoCmd.OpenForm while the report is open, it doesn't work - instead, it will wait until you close the report to open the form.

What is the best solution to this? I know I could build a custom toolbar just for the report, but that will take precious screen space, and I have disabled all toolbars at startup.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:52
Joined
Oct 29, 2018
Messages
13,686
Hi. By toolbars, does that include the Ribbon?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:52
Joined
Oct 29, 2018
Messages
13,686
In that case, I think the "best" solution might be to fix your Report View. Is it fixable?

PS. Also, would minimizing the Ribbon still not acceptable?
 

zeroaccess

Active member
Local time
Today, 07:52
Joined
Jan 30, 2020
Messages
631
In that case, I think the "best" solution might be to fix your Report View. Is it fixable?

PS. Also, would minimizing the Ribbon still not acceptable?
The latest version of my report uses a subreport to properly display the data structure. In order to prevent subreport headers from appearing when there is no data, I am using Cancel = True on the No Data event. Code doesn't run in Report View, so only Print Preview can display this report properly. Unless you know of another way?

Also, can you explain what you mean by minimizing the ribbon? Do you mean with the little arrow? No, I run with only the title bar and no ribbon at all. This is partly to lock down the app and partly to save screen space.
 

isladogs

CID VIP
Local time
Today, 13:52
Joined
Jan 14, 2017
Messages
14,221
You seem to be making this unnecessarily complex. This works for me.

Add a timer event to your report and set the interval to e.g. 2000 to ensure a short delay of 2s when the report opens.
Then in your timer event code, use something like
SQL:
Private Sub Report_Timer()
DoCmd.OpenForm "YourFormName" ', , , , , acDialog
Me.TimerInterval = 0 'reset the timer to zero so it only runs once
End Sub

My tests indicate you may not need the acDialog argument If using overlapping windows display option.
If you have tabbed documents, either use the acDialog argument or make the form a popup.
 
Last edited:

zeroaccess

Active member
Local time
Today, 07:52
Joined
Jan 30, 2020
Messages
631
Thanks Colin.

After what event does the timer start?

Edit: test shows form opens during Report View, but not during Print Preview. If this is a fundamental Access restriction, I'm going to have to find another way.
 
Last edited:

zeroaccess

Active member
Local time
Today, 07:52
Joined
Jan 30, 2020
Messages
631
I might have to move the buttons off the report and onto the form - one for Print Preview, and the other to Print. The user would use Print Preview to view what it will look like in its current state, then close and hit Print on the form. Not the best workaround.
 
Last edited:

isladogs

CID VIP
Local time
Today, 13:52
Joined
Jan 14, 2017
Messages
14,221
Before posting I tried it in both report view and print preview. Both worked for me.
If necessary try increasing the timer interval slightly to ensure all form events that run at startup have completed before the timer runs.

I see no reason for you to do a work round like you described in your last post
 

zeroaccess

Active member
Local time
Today, 07:52
Joined
Jan 30, 2020
Messages
631
Increased to 5000.

Form opens while in Report View, nothing happens while in Print Preview.

Tried opening form in dialog first - Print Preview then waits until you close the form to appear. Opening Normal, both open.
 
Last edited:

isladogs

CID VIP
Local time
Today, 13:52
Joined
Jan 14, 2017
Messages
14,221
As stated it works for me with the very simple code I supplied.
If you want to upload a cut down version of your dB, I'll take a look at it
 

zeroaccess

Active member
Local time
Today, 07:52
Joined
Jan 30, 2020
Messages
631
I think I figured it out: there is a conflict between windows opening in acDialog. Not sure I'll be able to sort this one out as the report is opened from an acDialog form. That means if I don't open the Report in acDialog, it opens in the background. And, as long as the report is open in Print Preview in acDialog, I can't open the form with buttons in acDialog.
 

zeroaccess

Active member
Local time
Today, 07:52
Joined
Jan 30, 2020
Messages
631
It seems there are two options (that I am aware of). Given that Print Preview is required to show the report accurately, including the Cancel on No Data in the subreports so they disappear:
  1. Since Print Preview can not display my buttons like Report View could: move Print, Send to Outlook from report and onto form where report is normally invoked from. Have Print Preview button do its thing (3 buttons total).
  2. Use the right-click menu on Print Preview
    • Enable default shortcut menus for the database, develop custom shortcut menus for the forms where this will open up options I don't want users to have (my datasheet form where I can not turn off shortcut menus for the form or the column filters will disappear)
    • Open report non-maximized so that all right-click options remain available. Settle on a certain window size in twips that will work for all users
Are there any other options you can think of?
 

isladogs

CID VIP
Local time
Today, 13:52
Joined
Jan 14, 2017
Messages
14,221
Re post #14
Not sure why that should be true, but in my experience it is almost never necessary to open a form using acDialog. If you haven't a good reason, open it normally and if necessary use DoCmd.Restore… or open as a popup.

Re post #15
I think all of that is redundant

As previously stated, I think you are making this unnecessarily complicated
 

zeroaccess

Active member
Local time
Today, 07:52
Joined
Jan 30, 2020
Messages
631
My Data Entry form is opened in acDialog because I don't want users to click behind it and do other things in the DB at the same time. I need to ensure that is the only thing they are working on at that moment. And, opening it normally will mean someone is going to accidentally click to the sides and it's going to get lost behind another form. Dialog prevents that.

Maybe I could try an on Lost Focus, setfocus back to the form? Would that work? That may cause unintended issues.
 
Last edited:

isladogs

CID VIP
Local time
Today, 13:52
Joined
Jan 14, 2017
Messages
14,221
Try popup or close/hide other background objects.
 

zeroaccess

Active member
Local time
Today, 07:52
Joined
Jan 30, 2020
Messages
631
I created a custom shortcut menu for the report which seems to be working. Will do more testing later.
 

onur_can

Member
Local time
Today, 05:52
Joined
Oct 4, 2015
Messages
135
Do you do exactly what you want with the shortcut menu?
 

Users who are viewing this thread

Top Bottom