cancel button to stop report

W

Whitney

How can I program the Cancel button on a from to completely stop a report
from generating?

I tried ...
DoCmd.Close acReport, "rpt_Daily"
but that didn't work

I tried entering a similar command to stop the queries that generate when
the report is run, but that did nothing.

When I hit cancel, I get Enter Parameter Value for the data that would be
provided by the form (Date). If I hit cancel again, a blank report is
generated.

How can I prevent the additional pop ups and the blank report?
 
D

Dale Fye

I have not tried this, and have no idea whether it will work, but I would try
the following, or something along these lines.

1. Set the tag property of the Cancel button to "Run" when you click the
button to generate the report. Then, when you click the Cancel button,
change the Tag property to "Cancel".

2. Then, in one of your reports events (not sure which event to use, try
the Print event on the detail section), check to see whether the tag property
of the calling form is set to "Cancel". If it is, try closing the report
from that event.

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
W

Whitney

I'm not sure I understand what you mean. This is what I have for the Cancel
event...

Private Sub Cancel_Click()

DoCmd.Close acForm, "frm_Date_Selector"


End Sub

Private Sub Form_Open(Cancel As Integer)
Form_Open_Exit:
Exit Sub
End Sub

Private Sub OK_Click()
Me.Visible = False
End Sub
 
D

Dale Fye

OK, I tried what I had previously recommended, and it didn't work.

I also searched a variety of sources on the internet, and found nothing on
this subject. However, I did figure out something that seems to be working.

First, I created a function fnPrint( ) that I put in a code module. This
function looks like below, and returns a value indicating whether to continue
printing.

Public Function fnPrint(Optional PrintReport As Variant = Null) As Boolean

Static myValue As Variant

If IsEmpty(myValue) Then myValue = True
If Not IsNull(PrintReport) Then
myValue = PrintReport
End If
fnPrint = myValue

End Function

Next, I configured the command button on my form as follows.
1. Give it a caption that reads "Open &Report" or something like that
2. In the click Event of the button I entered code that looks like:

Private Sub cmd_Report_Click

IF me.cmd_Report.Caption = "&Cancel" Then
Call fnPrint(False)
me.cmd_Report.Caption = "Open &Report"
Else
Call fnPrint(True)
me.cmd_Report.Caption = "&Cancel"
docmd.OpenReport "reportName"
Endif

Endif

3. Then, I opened my report in design view. In each section of the report
(ReportHeader, PageHeader, Detail, PageFooter, ReportFooter), I selected
Format event, and entered the following code in that event. If you have
groupings in your report, you will also have to enter this code in the format
of the group headers and footers.

Me.PrintSection = fnPrint()


When I click the button, it opens the report and prints it directly to the
printer. If I click the Cancel button, it appears to interrupt that process
at whatever page has already been formatted.

Unfortunately, I don't have any reports that generate lots of pages, so I
was unable to test this with more than just a small data set. Let me know if
this works for you.

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
D

Debbie Gibbs

I need some help with my Windows Mail email....????
For the last 2 weeks at least, when I try to delete 1 message, 3 or more
delete, I can't get cursor to highlight and erase addresses before
forwarding, something is not right! Any suggestions...?
 
J

John W. Vinson

I need some help with my Windows Mail email....????
For the last 2 weeks at least, when I try to delete 1 message, 3 or more
delete, I can't get cursor to highlight and erase addresses before
forwarding, something is not right! Any suggestions...?

I suggest that you post in a group supporting Windows Mail. This isn't one.
The Microsoft webpage can be confusing and may have misled you; this is the
first alphabetical group in a list of many, and supports the database program
Microsoft Access.

Try

http://windowshelp.microsoft.com/co...&cr=US&r=beade823-9d14-4ad1-bde4-d4dd8dadff28

Mind the word wrap.
 

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

Top