Add code to close form

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

Guest

Hi There,

I'm guessing this is probably simple.

I have a form called frmWklyTrackingOptions that displays four command
buttons. Each button opens a different report. What I'd like to do is add
some code to the OnClick Event so that in addition to opening the report it
also closes frmWklyTrackingOptions.

Here's the code as it is now. Please let me know how to alter it to get the
desired effect.

Thanks,
YYY


Private Sub cmdAllUIRs_Click()
On Error GoTo Err_cmdAllUIRs_Click

Dim stDocName As String

stDocName = "RptWEEKLYUIRsPendingByDate"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdAllUIRs_Click:
Exit Sub

Err_cmdAllUIRs_Click:
MsgBox Err.Description
Resume Exit_cmdAllUIRs_Click

End Sub
 
Yeahyeahyeah said:
Hi There,

I'm guessing this is probably simple.

I have a form called frmWklyTrackingOptions that displays four command
buttons. Each button opens a different report. What I'd like to do is
add some code to the OnClick Event so that in addition to opening the
report it also closes frmWklyTrackingOptions.

Here's the code as it is now. Please let me know how to alter it to
get the desired effect.

Thanks,
YYY


Private Sub cmdAllUIRs_Click()
On Error GoTo Err_cmdAllUIRs_Click

Dim stDocName As String

stDocName = "RptWEEKLYUIRsPendingByDate"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdAllUIRs_Click:
Exit Sub

Err_cmdAllUIRs_Click:
MsgBox Err.Description
Resume Exit_cmdAllUIRs_Click

End Sub

Either before or after your OpenReport line add...

DoCmd.Close acForm, Me.Name
 

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

Back
Top