Open Report in Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I added a command button to a form to open a report.

The form has:

modal=yes, pop-up=yes, and maximized when opened.

I added this line to the command button's open procedure:

Me.Visible = False

Which seems to get the report to show, which is good (before that line, I
had to close the form before the report was visible).

But, when I close the report, I want the form to be visible as it was before
I opened the report. As it stands, when the report is closed, I get the
basic Access page that lists the various forms, reports, etc.

Any suggestions?

Thank you.
 
jdb said:
I added a command button to a form to open a report.

The form has:

modal=yes, pop-up=yes, and maximized when opened.

I added this line to the command button's open procedure:

Me.Visible = False

Which seems to get the report to show, which is good (before that
line, I had to close the form before the report was visible).

But, when I close the report, I want the form to be visible as it was
before I opened the report. As it stands, when the report is closed,
I get the basic Access page that lists the various forms, reports,
etc.

Any suggestions?

Thank you.

In the Close event of the report set the Form's Visible property back to True.
 
That seems like a good idea, but for whatever reason (such as a near complete
lack of undestand of VBA code), I couldn't get it to work.

So, I tried this:

Private Sub Report_Close()
Dim stDocName As String

stDocName = "SCHS Entry Form"
DoCmd.OpenForm stDocName
DoCmd.Maximize

End Sub

It works, sort of. If I hit the design view, it goes to the form, not
design view. And, it just doesn't seem as elegant as your solution.

Sooooo....any suggestions on how to code (exactly) the visible command, or
how to change the above code to make it better, would be appreciated.

Thank you.
 
jdb said:
That seems like a good idea, but for whatever reason (such as a near
complete lack of undestand of VBA code), I couldn't get it to work.

So, I tried this:

Private Sub Report_Close()
Dim stDocName As String

stDocName = "SCHS Entry Form"
DoCmd.OpenForm stDocName
DoCmd.Maximize

End Sub

It works, sort of. If I hit the design view, it goes to the form, not
design view. And, it just doesn't seem as elegant as your solution.

Sooooo....any suggestions on how to code (exactly) the visible
command, or how to change the above code to make it better, would be
appreciated.

Private Sub Report_Close()
Forms![SCHS Entry Form].Visible = True
End Sub
 
Back
Top