473,394 Members | 1,765 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,394 software developers and data experts.

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_BeforeUpdate (Cancel As Integer)
Exit_Form_BeforeUpdate:
Exit Sub

Err_Form_BeforeUpdate:

Const conErrDoCmdCancelled = 2501
If (err = conErrDoCmdCancelled) Then
Resume Exit_Form_BeforeUpdate
Else
MsgBox err.description
Resume Exit_Form_BeforeUpdate
End If

End Sub
Nov 12 '05 #1
1 2459
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_BeforeUpdate (Cancel As Integer)

Exit_Form_BeforeUpdate:
Exit Sub

Err_Form_BeforeUpdate:

Const conErrDoCmdCancelled = 2501
If (err = conErrDoCmdCancelled) Then
Resume Exit_Form_BeforeUpdate
Else
MsgBox err.description
Resume Exit_Form_BeforeUpdate
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_BeforeUpdate(Cancel As Integer)
On error GoTo Err_Routine

'assume the save operation will fail validation checks
Cancel = True
If IsNull(Me.Field1) then
msgbox "Field1 is required."
me.field1.setfocus
Elseif Me.Field2 <> 1 and Me.Field2 <> 2 then
msgbox "Field2 must be a 1 or 2
me.field2.setfocus
elseif Msgbox("Are you sure you want to save
changes?",vbYesNo,"ConfirmChanges) = 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
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...
4
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...
2
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...
8
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....
2
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...
4
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...
1
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...
2
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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
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...

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.