Add code to close form

Y

Yeahyeahyeah

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
 
R

Rick Brandt

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
 
Top