473,626 Members | 3,310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Canceling an input form

Quick question for you. I'm using a small form for users to input a range of
dates for a report (similar to the date range forms used in MS templates)
that has an ok and a cancel button. How can I set up the cancel button so
that is does just that? As it is right now, the event for the cancel button
is simply docmd.close but if I click this button, ms prompts me to enter
parameter values for begindate and enddate. If i cancel out of these
prompts, i get an error - "The OpenReport action was canceled" and if I
enter something or click ok to the prompts, the report opens with no data
for obvious reasons. How can I kill the whole process with the cancel
button?
Dec 21 '06 #1
4 2813
On Thu, 21 Dec 2006 03:00:06 GMT, Jimmy wrote:
Quick question for you. I'm using a small form for users to input a range of
dates for a report (similar to the date range forms used in MS templates)
that has an ok and a cancel button. How can I set up the cancel button so
that is does just that? As it is right now, the event for the cancel button
is simply docmd.close but if I click this button, ms prompts me to enter
parameter values for begindate and enddate. If i cancel out of these
prompts, i get an error - "The OpenReport action was canceled" and if I
enter something or click ok to the prompts, the report opens with no data
for obvious reasons. How can I kill the whole process with the cancel
button?
That error, Error 2501, is a common error caused when a report
opening is canceled.

Trap the error in whatever code event is used to open the report, i.e.

Private Sub Command12_Click ()
On Error GoTo Err_Handler
DoCmd.OpenRepor t "ReportName " ,acViewPreview

Exit_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error " & Err.Number & ' " & Err.Description
End If
Resume Exit_Sub
End Sub
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Dec 21 '06 #2

Jimmy wrote:
Quick question for you. I'm using a small form for users to input a range of
dates for a report (similar to the date range forms used in MS templates)
that has an ok and a cancel button. How can I set up the cancel button so
that is does just that? As it is right now, the event for the cancel button
is simply docmd.close but if I click this button, ms prompts me to enter
parameter values for begindate and enddate. If i cancel out of these
prompts, i get an error - "The OpenReport action was canceled" and if I
enter something or click ok to the prompts, the report opens with no data
for obvious reasons. How can I kill the whole process with the cancel
button?
Sounds like there's something here you're not telling. Did you base
your report on a parameter query? Don't. Pass filters in the Open
event of your report. Then if you cancel, nothing should happen. Your
button should have maybe one event

DoCmd.OpenRepor t "ReportName",.. .. <somewhere out here is the filter -
just a valid WHERE clause without the WHERE keyword>.

If you don't try to open the report, then you won't get any errors,
just no open report. So I guess it might help if you posted your code.

Pieter

Dec 21 '06 #3

<pi********@hot mail.comwrote in message
news:11******** **************@ t46g2000cwa.goo glegroups.com.. .
>
Sounds like there's something here you're not telling. Did you base
your report on a parameter query? Don't. Pass filters in the Open
event of your report. Then if you cancel, nothing should happen. Your
button should have maybe one event
Yes, the form/report is based on those used in many of MS templates. When
the user opens a report the onopen event opens a form frmDateRange where the
user inputs a beginning and ending date, clicks ok and then the report opens
and uses the two values from the date range form in the reports query to
limit the data displayed. What I am looking for is a way for the user to
cancel the date range form and have that form close and essentially the
report close (since I believe it is technically open already since the
calling of frmDateRange is in the reports onopen event).
>
DoCmd.OpenRepor t "ReportName",.. .. <somewhere out here is the filter -
just a valid WHERE clause without the WHERE keyword>.

If you don't try to open the report, then you won't get any errors,
just no open report. So I guess it might help if you posted your code.
Report's OnOpen event:
Private Sub Report_Open(Can cel As Integer)
DoCmd.OpenForm "frmReportDateR ange", , , , , acDialog
End Sub

Form frmDateRange onClick event for OK Button:
Private Sub cmdOK_Click()
If IsNull([BeginDate]) Or IsNull([EndDate]) Then
MsgBox "You must enter both beginning and ending dates."
DoCmd.GoToContr ol "BeginDate"
Else
If [BeginDate] [EndDate] Then
MsgBox "Ending date must be greater than Beginning date."
DoCmd.GoToContr ol "BeginDate"
Else
Me.Visible = False
End If
End If
End Sub

After clicking the OK button, the date range form becomes not visible and
the report becomes visible.

>
Pieter

Dec 21 '06 #4
Jimmy wrote:
<pi********@hot mail.comwrote in message
news:11******** **************@ t46g2000cwa.goo glegroups.com.. .
>>Sounds like there's something here you're not telling. Did you base
your report on a parameter query? Don't. Pass filters in the Open
event of your report. Then if you cancel, nothing should happen. Your
button should have maybe one event


Yes, the form/report is based on those used in many of MS templates. When
the user opens a report the onopen event opens a form frmDateRange where the
user inputs a beginning and ending date, clicks ok and then the report opens
and uses the two values from the date range form in the reports query to
limit the data displayed. What I am looking for is a way for the user to
cancel the date range form and have that form close and essentially the
report close (since I believe it is technically open already since the
calling of frmDateRange is in the reports onopen event).
>>DoCmd.OpenRep ort "ReportName",.. .. <somewhere out here is the filter -
just a valid WHERE clause without the WHERE keyword>.

If you don't try to open the report, then you won't get any errors,
just no open report. So I guess it might help if you posted your code.


Report's OnOpen event:
Private Sub Report_Open(Can cel As Integer)
DoCmd.OpenForm "frmReportDateR ange", , , , , acDialog
End Sub

Form frmDateRange onClick event for OK Button:
Private Sub cmdOK_Click()
If IsNull([BeginDate]) Or IsNull([EndDate]) Then
MsgBox "You must enter both beginning and ending dates."
DoCmd.GoToContr ol "BeginDate"
Else
If [BeginDate] [EndDate] Then
MsgBox "Ending date must be greater than Beginning date."
DoCmd.GoToContr ol "BeginDate"
Else
Me.Visible = False
End If
End If
End Sub

After clicking the OK button, the date range form becomes not visible and
the report becomes visible.
Also, don't forget to close "frmReportDateR ange" after it closes:

Private Sub Report_Open(Can cel As Integer)
DoCmd.OpenForm "frmReportDateR ange", , , , , acDialog
' execution pauses at the line above until form is closed or hidden
' close the hidden form
DoCmd.Close acForm, "frmReportDateR ange"
End Sub

--
'---------------
'John Mishefske
'---------------
Dec 22 '06 #5

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

Similar topics

2
7232
by: J. W. McCall | last post by:
I'm working on a MUD server and I have a thread that gets keyboard input so that you can enter commands from the command line while it's in its main server loop. Everything works fine except that if a player enters the 'shutdown' command, everything shuts down, but the input thread is still sitting waiting for enter to be pressed for raw_input. After enter is pressed, it exits back to the command prompt as it should. I'm wondering if...
7
2978
by: greg brant | last post by:
i have a form made up of 2 file inputs and a submit button.. the imputs are to upload images, namley jpeg's for a e-greatings thing im working on. this only works with jpegs so i have a script that will check the value of the imput tag to make sure it ends with .jpg, .jpeg. this works fine on the jubmit button using onclick="myHandler(this)"
1
1287
by: Gary Brown | last post by:
Hi, If window creation cannot continue how is it cancelled within an Load event handler? Setting DialogResult to Cancel does nothing and Close() is not allowed. The form is shown modelessly so returning a value directly to the parent is meaningless. I am using .NET 1.1.
4
4058
by: welie | last post by:
I have a problem canceling a check box update when placing a check in it. Checkbox is not bound. Here is what happens. User clicks a check box. In the BeforeUpdate method of the control, if the check box is being checked, some validation is performed. If the validation fails, I set cancel to true, and the check box is not checked afterwards. This is fine.
1
1278
by: Lance | last post by:
I want to prevent a form from closing when the user clicks the form's Close button in the form's ControlBox (i.e., the button with the "X" in the upper-right corner of the form). Instead, I just want to hide the form. My idea is to do something like the following Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs e.Cancel = Tru MyBase.OnClosing(e Me.Visible = Fals End Su This technique seems to work...
6
1607
by: Kevin | last post by:
I come up with these questions during the day, do some research, and then look for experienced users' input. 1. In Access, we already know it's pretty much an automatic save if you enter data. How can I prevent that? How can I make an effective way in Access to not commit a change until a 'Save' button is pressed, and also to backout changes using a 'Cancel' button? 2. Let's say I have 15 objects on a form, and they're locked. I have...
0
1640
by: rcarmich | last post by:
I am having an issue canceling a beginReceive call on a timeout. For example, the following function: public int ReadBytes(Socket theSock, byte arr, int startByte, int length, int timeout) { IAsyncResult result = theSock.BeginReceive(arr, startByte, length, SocketFlags.None, null, null); if (result.AsyncWaitHandle.WaitOne(timeout, false) ==
2
1830
TonFrere
by: TonFrere | last post by:
Hello, I'm building a solution using Visual Studio Windows Forms and I'm coding in C#. I have a windows form with databinded textboxes, comboboxes and a datagrid. Everything works fine until a user enter a wrong value in a textbox binded to a numeric field on the form. There is no way to get back to the old value by pressing escape (canceling changes). Strangely, this works fine with the datagridview columns: if there is an error in a...
3
1565
by: bonus | last post by:
Im new at Javascripting and jumped in the ocean and Im a little lost, I am trying to get a form to do 2 things: 1) write a cookie (actually several cookies) 2) submit the information to a php file If the site is coded for one of the commands (either one) the command follows the submit. I have tried various ways to recode the form but for some reason I can't make both happen on submit; depending on which variable is first I either get...
0
8713
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...
0
8644
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8370
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
8514
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
7206
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4094
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...
1
2632
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
1
1817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1516
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.