Cancel a Report from a form

G

Guest

When I open a report, I have the report open a form on open to get filter
information from the user. One of the options I want is from the filter form
the abilitlity to cancel the report that opened the form. I have tried the
following:

Dim stDocName As String
stDocName = Me.Rep_No 'Name of Report
DoCmd.Close 'Close the filter form
Reports(stDocName).Cancel = True 'Cancel the report

and it does not work. Please help this is time critical.

Thanks Chris
 
G

Guest

Thanks for answering, however, when I tried your solution I got the
following: "this action can't be carried out while processing a form or rpert
event"
 
G

Guest

The report open event can be canceled. When the cancel button is clicked on
you form, you will need to return some value to the report that will tell it
to cancel the open event.
 
G

Guest

I guess that is what I am asking then, how do I pass a value back to the
report from the form?
 
G

Guest

How is the report getting its parameter from the form?
I ask this so we can make the change as simple as possible.
 
G

Guest

When the report is open, the following code is used:

Private Sub Report_Open(Cancel As Integer)
Me.Filter = ""
Me.FilterOn = True
DoCmd.OpenForm "Frm_Rpt_Filter", , , "Rep_No='PR07002-C'", , acDialog
End Sub

When Thr Frm_Rpt_Filter opens, the following code is used:
' Close the form and open the report
DoCmd.Close
DoCmd.OpenReport stDocName, acViewPreview, , sFilter, acWindowNormal
DoCmd.Maximize

Not all of the reports opened from this menu require the filter form so
I can not put the code just in the form. The second problem is that about
50% or the reports have the option to run a summary or detailed report than
just hides the detail line. The following code does that for me, but can
only be run in the form and the report must be loaded to work.

If tds = "Summary" Then
Reports(stDocName).Detail.Visible = False
Else
Reports(stDocName).Detail.Visible = True
End If
Hope this helps.

Chris
 
G

Guest

what did Klatuu write: in the last responce?

DDBeards said:
When the report is open, the following code is used:

Private Sub Report_Open(Cancel As Integer)
Me.Filter = ""
Me.FilterOn = True
DoCmd.OpenForm "Frm_Rpt_Filter", , , "Rep_No='PR07002-C'", , acDialog
End Sub

When Thr Frm_Rpt_Filter opens, the following code is used:
' Close the form and open the report
DoCmd.Close
DoCmd.OpenReport stDocName, acViewPreview, , sFilter, acWindowNormal
DoCmd.Maximize

Not all of the reports opened from this menu require the filter form so
I can not put the code just in the form. The second problem is that about
50% or the reports have the option to run a summary or detailed report than
just hides the detail line. The following code does that for me, but can
only be run in the form and the report must be loaded to work.

If tds = "Summary" Then
Reports(stDocName).Detail.Visible = False
Else
Reports(stDocName).Detail.Visible = True
End If
Hope this helps.

Chris
 

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

Similar Threads

How would i refer to a closed report? 8
Bypass Enter Parameter Value 2
Exporting a Report to Excel 2
Applying a filter on a report 2
stLinkCriteria 3
Link Criteria 1
Combo Box & Report Questions 22
can't find form 4

Top