473,666 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Can cel 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 "frmSelectOpChe ckVars", , , , , acDialog

Set tv = New TaggedValues
tv.Text = Forms!frmSelect OpCheckVars!txt MyTags.Tag
' Close the selection form
DoCmd.Close acForm, "frmSelectOpChe ckVars"

If tv.Item("Cancel ed") = "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 1639
Start with the following code somewhere:
DoCmd.openRepor t ......
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 "MyParameterFor m",,,,,acDia log
If IsLoaded("MyPar ameterForm") = 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, "MyParameterFor m"

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

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******@pcdata sheet.com
www.pcdatasheet.com

"Denise" <dh*****@gmail. com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.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(Can cel 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 "frmSelectOpChe ckVars", , , , , acDialog

Set tv = New TaggedValues
tv.Text = Forms!frmSelect OpCheckVars!txt MyTags.Tag
' Close the selection form
DoCmd.Close acForm, "frmSelectOpChe ckVars"

If tv.Item("Cancel ed") = "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
342
by: Aadam | last post by:
Does Microsoft have a best practices for tracking errors? (like in a database, what info, etc)
2
1960
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 securing the server. Included in this was revoking public access to the system table objects. Can someone post the URL where I can pick this up, or drop me a note on contacting them for a copy of the document?
136
9308
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
13
2274
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, Option4 = 3
2
1813
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) Group relevant .aspx files into subfolders within your project etc.
4
1821
by: Luis Esteban Valencia | last post by:
Hello. Can somebody recomend me books of design patterns in c# and best practices too.
10
3438
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 somewhere that each folder under the "web site" is compiled in separate assembly. I however, did not find that the "web site" creation in vs.net 2005 created any AssemblyInfo.cs file.
0
1693
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 design of the database for a new project, but I am unsure as to the best practice when one wants to store data relating to combinations of arbitrary numbers of sets of data. For example, take the following two groups of sets, each containing...
10
2982
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? public class MyClass private _variableName as integer public property VariableName as integer
1
1651
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, Microsoft approved practices for every aspect of the lifecycle - so planning and architecture, team development, testing procedures, change control and bug-tracking, version control - etc etc. What software to use, which
0
8454
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8363
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8883
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8561
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8645
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.