473,545 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prevent DoCmd Cancel Message From Appearing

Although I have used the code below to suppress the DoCmd cancel
action message from appearing on lots of other actions such as preview
and print, I have not been able to get to work on a BeforeUpdate Event
Procedure. There is nothing elaborate about the event, however, there
is an initial message box stating that if one field contains data then
a second one must also, and then after clicking okay, the
DoCmdMenuItem action box is displayed.

Any suggestions on addressing this problem will be appreciated.
Thanks.
Private Sub Form_BeforeUpda te (Cancel As Integer)
Exit_Form_Befor eUpdate:
Exit Sub

Err_Form_Before Update:

Const conErrDoCmdCanc elled = 2501
If (err = conErrDoCmdCanc elled) Then
Resume Exit_Form_Befor eUpdate
Else
MsgBox err.description
Resume Exit_Form_Befor eUpdate
End If

End Sub
Nov 12 '05 #1
1 2464
Dalan wrote:
Although I have used the code below to suppress the DoCmd cancel
action message from appearing on lots of other actions such as preview
and print, I have not been able to get to work on a BeforeUpdate Event
Procedure. There is nothing elaborate about the event, however, there
is an initial message box stating that if one field contains data then
a second one must also, and then after clicking okay, the
DoCmdMenuItem action box is displayed.

Any suggestions on addressing this problem will be appreciated.
Thanks.

Private Sub Form_BeforeUpda te (Cancel As Integer)

Exit_Form_Befor eUpdate:
Exit Sub

Err_Form_Before Update:

Const conErrDoCmdCanc elled = 2501
If (err = conErrDoCmdCanc elled) Then
Resume Exit_Form_Befor eUpdate
Else
MsgBox err.description
Resume Exit_Form_Befor eUpdate
End If

End Sub


What are you ":canceling " in the before update event? Are you calling a
routine that recalls the BeforeUpdate event? Cancel is used to inform
Access whether or not the record can be saved.

Here is some example code:
Private Sub Form_BeforeUpda te(Cancel As Integer)
On error GoTo Err_Routine

'assume the save operation will fail validation checks
Cancel = True
If IsNull(Me.Field 1) then
msgbox "Field1 is required."
me.field1.setfo cus
Elseif Me.Field2 <> 1 and Me.Field2 <> 2 then
msgbox "Field2 must be a 1 or 2
me.field2.setfo cus
elseif Msgbox("Are you sure you want to save
changes?",vbYes No,"ConfirmChan ges) = vbYes then
'validation checks passes and user confirmed save
Cancel = False
endif

Exit_Routine:
Exit Sub

Err_routine
msgbox Err.description
Resume Exit_Routine
End Sub
Nov 12 '05 #2

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

Similar topics

22
7536
by: alecjames1 | last post by:
I have a form which the user must complete before closing. I have disabled the window x button and use my own exit button. When selected it checks to see if the user has completed the entries otherwise it cancels the close. However, the user can still right click on the task bar and close my application. Is there any way of preventing this....
4
5842
by: deko | last post by:
I have a pop-up form in which user-defined parameters are entered. The parameters are entered into a subform datasheet which is bound to a table. I need to check the product of two parameters to make sure they are valid before updating them (or closing the popup form), so I use this code: Private Function BadValue() As Boolean If Me!Die *...
2
3519
by: kevininstructor | last post by:
I want to prevent a user from closing an application while doing critical operations. The following code (concept came from MSDN) works except for when the user attempts to terminate via "Task List" which causes "Program not responding"...press "Cancel" and no issues, press "End now" and sure enough it ends. My question is; is there any...
8
8705
by: Fred Zuckerman | last post by:
I'd like to prevent users from accidently going into design view of a form and screwing it up. I've googled the group and have found that the normal method is to use MDE or user level security. I'd like to avoid both of those options as I'm only trying to stop accidental changes, not willful misconduct. These mdb's are too quick/simple to...
2
2424
by: Lauren Wilson | last post by:
Hi folks, I believe I have seen this in this group in the past but my search comes up with nothing so far. I want to prevent our Access application from closing without some kind of confirmation from the user. We already have a tiny hidden form that loads from a function called by the autoexec macro. I KNOW it is loading because I...
4
3116
by: tlyczko | last post by:
I have been looking on the NGs and I found this code to show if a subform has no records. I have this code in the MAIN form OnClose event: Private Sub btnClose_Click() '4/16/06 new code that cancels the close event if the BeforeUpdate code fires '4/16/06 see...
1
1843
by: dee | last post by:
I can prevent a duplicate ID from being entered, but can't figure out how to go to the record with that already existing ID. Could someone help? Thanks in advance. Private Sub ID_BeforeUpdate(Cancel As Integer) If Not IsNull(DLookup("ID", "contacts", _ "ID = " & Me!ID)) Then
2
5505
by: John | last post by:
I have the code beneath to create a mail message. It needs to be edited manually before it gets send. It works well if the editor indeed sends the message. But if he cancels the message, Access will give an error message saying the sendobject command has been canceled. I tried to use DoCmd.SetWarnings to prevent this from happening but no...
4
6641
by: gazza10001 | last post by:
Hi i hope you can help my company uses access and has modified for its needs usually what happens is you serach for the invoice by its number and then it brings all the information up such as entry fields and so there is a button you press which then takes to through to a print preview of the invoice and you print out the invoice but recent ly...
0
7415
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...
0
7928
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...
1
7440
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...
0
7775
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...
1
5344
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3470
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...
1
1902
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
1030
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
726
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...

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.