473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Best practices for canceling out of a report?

How do I get the report to not spend time pulling up the data when I'm
going to bail out of the report anyway?

Below is the code in my report. I first show the user a form where
they can select some filtering parameters which I put in Getz's
TaggedValues class. But they can hit a Cancel button if they decide
they don't want any report. When I test the Cancel button I'd like the
report to close immediately but it seems to spend some time pulling up
data first.

(I've tried to put docmd.Close in the Report_Open but that closes the
whole database so I've been putting it in the Report_Activate.)

The Record Source is a query and the report has no fields that are
calculated, all fields are straight from the query.

Any advice?
THANKS!

----- Here is the code...

Option Compare Database
Option Explicit
Public CloseNow As String ' I know boolean would be better

Private Sub Report_Open(Cancel As Integer)
Dim strMyFilter As String
Dim tv As TaggedValues

CloseNow = "No" ' Public string

' This form sets TaggedValues in both OK and Close
' buttons, then sets its Visibile = false
DoCmd.OpenForm "frmSelectOpCheckVars", , , , , acDialog

Set tv = New TaggedValues
tv.Text = Forms!frmSelectOpCheckVars!txtMyTags.Tag
' Close the selection form
DoCmd.Close acForm, "frmSelectOpCheckVars"

If tv.Item("Canceled") = "Yes" Then
MsgBox "Click OK to close. This may take a few seconds... ", ,
"REPORT CLOSING"
CloseNow = "Yes"
Else
' set strMyFilter here...
Me.Filter = strMyFilter
Me.FilterOn = True
End If ' end of If canceled = yes

Set tv = Nothing

End Sub

Private Sub Report_Activate()
If CloseNow = "Yes" Then
DoCmd.Close
End If
End Sub

Nov 13 '05 #1
2 1628
Start with the following code somewhere:
DoCmd.openReport ......
On Error Resume Next
The On Error code is necessary because Access will raise an error when you
cancel the report.

Put your code to open your form where users can select some filtering
parameters in the Report's Open event. The code would look like:
DoCmd.OpenForm "MyParameterForm",,,,,acDialog
If IsLoaded("MyParameterForm") = False Then
Cancel = True
End If
(You can find the code for the IsLoaded function in NorthWind's standard
modules.)

You will need a button on the form to Continue after the users select the
parameters. The Continue button code would be:
Me.Visible = False

Put the following code in the Cancel button's Click event:
DoCmd.Close acForm, "MyParameterForm"

Put the following code in the Report's Close event:
DoCmd.Close acForm, "MyParameterForm"

The form doesn't load unless you select parameters and Click the Continue
button so it won't prematurely pull up any data.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"Denise" <dh*****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
How do I get the report to not spend time pulling up the data when I'm
going to bail out of the report anyway?

Below is the code in my report. I first show the user a form where
they can select some filtering parameters which I put in Getz's
TaggedValues class. But they can hit a Cancel button if they decide
they don't want any report. When I test the Cancel button I'd like the
report to close immediately but it seems to spend some time pulling up
data first.

(I've tried to put docmd.Close in the Report_Open but that closes the
whole database so I've been putting it in the Report_Activate.)

The Record Source is a query and the report has no fields that are
calculated, all fields are straight from the query.

Any advice?
THANKS!

----- Here is the code...

Option Compare Database
Option Explicit
Public CloseNow As String ' I know boolean would be better

Private Sub Report_Open(Cancel As Integer)
Dim strMyFilter As String
Dim tv As TaggedValues

CloseNow = "No" ' Public string

' This form sets TaggedValues in both OK and Close
' buttons, then sets its Visibile = false
DoCmd.OpenForm "frmSelectOpCheckVars", , , , , acDialog

Set tv = New TaggedValues
tv.Text = Forms!frmSelectOpCheckVars!txtMyTags.Tag
' Close the selection form
DoCmd.Close acForm, "frmSelectOpCheckVars"

If tv.Item("Canceled") = "Yes" Then
MsgBox "Click OK to close. This may take a few seconds... ", ,
"REPORT CLOSING"
CloseNow = "Yes"
Else
' set strMyFilter here...
Me.Filter = strMyFilter
Me.FilterOn = True
End If ' end of If canceled = yes

Set tv = Nothing

End Sub

Private Sub Report_Activate()
If CloseNow = "Yes" Then
DoCmd.Close
End If
End Sub

Nov 13 '05 #2
Yes, that worked perfectly!

Thanks for the quick response.

Denise

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Aadam | last post by:
Does Microsoft have a best practices for tracking errors? (like in a database, what info, etc)
2
by: byrocat | last post by:
I'm chasing after a documetn that was available on one of the Microsoft websites that was titled somethign like "MS SQL Server Best Practices" and detailed a nyumber of best practices about...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
13
by: john doe | last post by:
A quick question, about so-called 'best practices', I'm interested in which of A/B of the two examples people would choose, and why. public enum MyEnum { Option1 = 0, Option2 = 1, Option3 =...
2
by: Amelyan | last post by:
Could anyone recommend a book (or a web site) that defines best practices in ASP.NET application development? E.g. 1) Precede your control id's with type of control btnSubmit, txtName, etc. 2)...
4
by: Luis Esteban Valencia | last post by:
Hello. Can somebody recomend me books of design patterns in c# and best practices too.
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
0
by: Louis Aslett | last post by:
I hope this is the correct newsgroup for this query (if not please give me a pointer to where is best): I understand the theory of normalisation etc and am trying to follow best practices in the...
10
by: Ren | last post by:
Hi All, I'm still rather new at vb.net and would like to know the proper way to access private varibables in a class. Do I access the variable directly or do I use the public property? ...
1
by: Pablo | last post by:
Hello all, Hope today finds you well. I'm looking to take my knowledge of best practices within the development lifecycle to the next level. Basically I want to follow industry recognised,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.