Close Date Range Form After Report Previewed

  • Thread starter Thread starter sandpking
  • Start date Start date
S

sandpking

How do I get the calling form to close after the user previews the
report. Thanks in advance.

I tried adding a docmd.close acform on the report's close event, but
it didn't work.

Here is the code on the button calling the report.

On Error GoTo Err_CloseImportForm_Click

DoCmd.OpenReport "Rpt_How_Error_Discovered", acViewPreview, acNormal

'DoCmd.Close ****** This command closed the report too quickly
***********

Exit_CloseImportForm_Click:
Exit Sub

Err_CloseImportForm_Click:
MsgBox Err.Description
Resume Exit_CloseImportForm_Click
 
Hi,
tell access what you want to close.
Replace DoCmd.Close
with
DoCmd.Close acForm, Me.Name

Jeanette Cunningham
 
Hi,
tell access what you want to close.
Replace DoCmd.Close
with
DoCmd.Close acForm, Me.Name

Jeanette Cunningham
The form has to stay because the report includes the date range in the
heading. It asked me for the start and end date on the calling form.
Any more ideas?
 
I'm thinking I need some code on the report's close event. This
doesn't work.

Private Sub Report_Close()

If CurrentProject.AllForms("Frm_Date_Range").IsLoaded Then
DoCmd.Close acForm, Me.Name

End If

End Sub
 
almost correct,

Private Sub Report_Close()

If CurrentProject.AllForms("Frm_Date_Range").IsLoaded Then
DoCmd.Close acForm, "Frm_Date_Range"
End If

End Sub

Should do it for you.


Jeanette Cunningham


I'm thinking I need some code on the report's close event. This
doesn't work.

Private Sub Report_Close()

If CurrentProject.AllForms("Frm_Date_Range").IsLoaded Then
DoCmd.Close acForm, Me.Name

End If

End Sub
 
almost correct,

Private Sub Report_Close()

If CurrentProject.AllForms("Frm_Date_Range").IsLoaded Then
DoCmd.Close acForm, "Frm_Date_Range"
End If

End Sub

Should do it for you.

Jeanette Cunningham

I'm thinking I need some code on the report's close event. This
doesn't work.

Private Sub Report_Close()

If CurrentProject.AllForms("Frm_Date_Range").IsLoaded Then
DoCmd.Close acForm, Me.Name

End If

End Sub

Regarding your code...
Private Sub Report_Close()

If CurrentProject.AllForms("Frm_Date_Range").IsLoaded Then
DoCmd.Close acForm, Me.Name

End If

End Sub

To expand upon what Jeanette has written, your reference to
Me.Name in the above Report's Close event is what is causing your
problem.
The Me keyword refers to whatever form or report object the code is
written in. In this case Me is the Report object, so Me.Name is the
name of the Report, not the name of the form you wish to close.

I hope this clarify's Me for you.
 
Back
Top