Problems generating reports from a modal dialog

H

Hector

Hi, I have two related problems, when generating reports from a modal dialog
box.

The dialog box accepts report criteria and then either previews or prints
the report depending on a choice made from the main menu. The main menu is
used to enter the criteria applicable to all reports that can be generated
and I thought I'd use a dialog box to accept the unique criteria applicable
to this one report.
Still with me? :)

Prob 1. When previewing the report. The report is generated and the dialog
box closes ok but I want the focus to switch to the new tab containing the
report and not the menu form. Can't get that working.

Prob 2. When printing the report. I get a system msg telling me the report
is printing but my report isn't printed and the dialog box doesn't close. It
goes into some black hole somewhere - not even shown in the print queue. Its
using the default printer and other apps print ok.

This is the VB code I'm using for the dialog box's OK button.

DoCmd.OpenReport "Attendance Report", Me.OpenArgs, , sqlText
DoCmd.Close acForm, "Attendance Dialog", acSaveNo

Me.OpenArgs comes from the initial menu and is either acViewNormal or
acViewPreview.
sqlText is the additional report criteria.

Any thoughts? Thanks in advance
 
J

Jeanette Cunningham

When you close the dialog form, the remaining code (on the main form) in the
sub that opened the dialog form will continue on the row below the row that
opened the dialog form.
That will put the focus back on the main form.

You could put a line of code to hide the main menu form just before the code
that opens the report.

Instead of closing the attendance dialog, just make it hidden (visible =
No).

When the report closes, you can close the attendance dialog and make the
main menu form visible.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
D

De Jager

Hector said:
Hi, I have two related problems, when generating reports from a modal
dialog
box.

The dialog box accepts report criteria and then either previews or prints
the report depending on a choice made from the main menu. The main menu is
used to enter the criteria applicable to all reports that can be generated
and I thought I'd use a dialog box to accept the unique criteria
applicable
to this one report.
Still with me? :)

Prob 1. When previewing the report. The report is generated and the dialog
box closes ok but I want the focus to switch to the new tab containing the
report and not the menu form. Can't get that working.

Prob 2. When printing the report. I get a system msg telling me the report
is printing but my report isn't printed and the dialog box doesn't close.
It
goes into some black hole somewhere - not even shown in the print queue.
Its
using the default printer and other apps print ok.

This is the VB code I'm using for the dialog box's OK button.

DoCmd.OpenReport "Attendance Report", Me.OpenArgs, , sqlText
DoCmd.Close acForm, "Attendance Dialog", acSaveNo

Me.OpenArgs comes from the initial menu and is either acViewNormal or
acViewPreview.
sqlText is the additional report criteria.

Any thoughts? Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top