Closing Forms After Opening A Report

  • Thread starter Thread starter Roger Lord
  • Start date Start date
R

Roger Lord

I'm having a strange problem involving forms that open
forms. I can only describe it as follows:

I have 3 forms (Form A, B, and C) and 2 reports.

Form A is a "main" form that opens Form B or Form C.

Form B can open a report and Form C can open a report.

Both Form B and C have listboxes that the user can select
from and then use the selection to open and fill a report
for printing.

Here's how Form A opens the other forms:

DoCmd.OpenForm "B", acNormal, , , , acDialog

Here's the problem...

If I open Form B and then close it without opening a report,
I can go on to open Form C and everything works fine.

On the other hand, if I open Form B, open a report, and then
close Form B, my attempt to open Form C results in Form B
opening again. If I close Form B after this unexpected
visit, then I can go on to Form C as before. Opening the
report is what makes things go wrong. This is also the case
if I first open Form C, open a report, close Form C, and
then try to open Form B. I re-visit Form C unexpectedly.

Here's how I close each form...

DoCmd.Close acForm, "C", acSaveNo

Here's how I open a report (for immediate print without a
preview)...

DoCmd.OpenReport "MyReport", acViewNormal

Does anybody have any idea why opening a report from either
Form B or C causes the close sequence to get messed up?

Thanks,
Roger
 
Two things strike me:

1. The "dialog" parameter of your form open command, causes all code
execution to halt until you respond. Perhaps changing to a pop-up and/or
modal form would work as well.

2. If your running the close form code from the form you wish to close, then
just "DoCmd.Close" will do. Not sure why you'd not want to save data
changes on close.

-Ed
 
That did the trick!

Thanks much,
Roger


Two things strike me:

1. The "dialog" parameter of your form open command, causes all
code
execution to halt until you respond. Perhaps changing to a
pop-up and/or
modal form would work as well.

2. If your running the close form code from the form you wish to
close, then
just "DoCmd.Close" will do. Not sure why you'd not want to save
data
changes on close.

-Ed
 
Back
Top