473,659 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

On cancel=true, extra Access-warning?

Hi all

I come across a 'feature' of Access (2000) that I don't like and would like to disable.
I am checking if a value already exists in a table.

I a subform I use code like :
Private Sub Choice_BeforeUp date(Cancel As Integer)
If <validation on inputted value already in table is true> Then
MsgBox "This choice already exists...", vbCritical, "Validation "
Cancel = True
End If
End Sub

My msgbox appears and the update is cancelled when the input is trapped by my validation,
but after I click OK Access also comes with a info-message:
"The value in the field or record is violating ...."
I would like to disable this second warning.

If I don't use cancel=true then the second message doesn't come up !
Any idea's?

Trap unsolved errors is 'on' in the vb-editor.

Thanks
Arno R


Nov 13 '05 #1
6 6662
Arno R wrote:
Hi all

I come across a 'feature' of Access (2000) that I don't like and would like to disable.
I am checking if a value already exists in a table.

I a subform I use code like :
Private Sub Choice_BeforeUp date(Cancel As Integer)
If <validation on inputted value already in table is true> Then
MsgBox "This choice already exists...", vbCritical, "Validation "
Cancel = True
End If
End Sub

My msgbox appears and the update is cancelled when the input is trapped by my validation,
but after I click OK Access also comes with a info-message:
"The value in the field or record is violating ...."
I would like to disable this second warning.

If I don't use cancel=true then the second message doesn't come up !
Any idea's?


I'm not familiar with the error format you're using, ie " If
<validation on inputted value already in table is true> " (I always use
GoTo Err_Proc at the beginning of any sub and have a select case
err.number after Err_Proc: at the end of the procedure.

IN anyevent, what you want to do is trap this error at the form level,
in the form On Error event.

The first thing to do is find out what error number this is. It should
be displayed on the error message you're getting that you don't like.
Or you can press Help to find the err.number. I'll use x in the
procedure below.

Next put this into the on error event of your form. The response =
acdataerrcontin ue is what bypasses the Access error message:

Private Sub Form_Error(Data Err As Integer, Response As Integer)

Select Case DataErr

Case <your error number>

Msgbox <your message>

<your error handling, if any>

Response = acDataErrContin ue

Case Else

Response = acDataErrDispla y

End Select

End Sub

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #2
Tim Marshall wrote:
Arno R wrote:
Hi all

I come across a 'feature' of Access (2000) that I don't like and would
like to disable.
I am checking if a value already exists in a table.

I a subform I use code like :
Private Sub Choice_BeforeUp date(Cancel As Integer)
If <validation on inputted value already in table is true> Then
MsgBox "This choice already exists...", vbCritical, "Validation "
Cancel = True
End If
End Sub

My msgbox appears and the update is cancelled when the input is
trapped by my validation,
but after I click OK Access also comes with a info-message:
"The value in the field or record is violating ...."
I would like to disable this second warning.

If I don't use cancel=true then the second message doesn't come up !
Any idea's?

I'm not familiar with the error format you're using, ie " If <validation
on inputted value already in table is true> " (I always use GoTo
Err_Proc at the beginning of any sub and have a select case err.number
after Err_Proc: at the end of the procedure.

IN anyevent, what you want to do is trap this error at the form level,
in the form On Error event.

The first thing to do is find out what error number this is. It should
be displayed on the error message you're getting that you don't like. Or
you can press Help to find the err.number. I'll use x in the procedure
below.

Next put this into the on error event of your form. The response =
acdataerrcontin ue is what bypasses the Access error message:

Private Sub Form_Error(Data Err As Integer, Response As Integer)

Select Case DataErr

Case <your error number>

Msgbox <your message>

<your error handling, if any>

Response = acDataErrContin ue

Case Else

Response = acDataErrDispla y

End Select

End Sub


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Beside what Tim says - your table definition, or control "Choice," may
have a Validation Rule that is being evaluated after the BeforeUpdate
event. Either let that Validation Rule/Validation Text handle the
validation, or set those properties to empty strings.

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQgQTAIechKq OuFEgEQL1bQCdFD aHeqkbwfGkle7S3 6Wvg4hO65sAoI9+
kH+gK/qf3lKPH473Oo68g PDV
=VkwY
-----END PGP SIGNATURE-----
Nov 13 '05 #3
Hi Tim and MGFoster,
The first thing to do is find out what error number this is. It should be displayed on the error
message you're getting that you don't like. Or you can press Help to find the err.number. I'll
use x in the procedure below.


Strange case is that there was no err.number displayed.
I was able to find the Err number. It was 2116. With code like:
Private Sub Form_Error(Data Err As Integer, Response As Integer)
Select Case DataErr
Case 0
Case Else
MsgBox DataErr
End Select
End sub

Now the code is like:
Private Sub Form_Error(Data Err As Integer, Response As Integer)
Select Case DataErr
Case 2116 'Unneeded Access-warning
Response = acDataErrContin ue
Case Else
Response = acDataErrDispla y
End Select
End Sub

Problem is 'solved' now but ...
I still don't understand why Access comes up with this error in the first place ...
There is NO validation set in the table, no validation in the fields, no validation in the form.
I was thinking about corruption ? (already tried /decompile)

Thanks
Arno R
Nov 13 '05 #4
Arno R wrote:
Hi Tim and MGFoster,

The first thing to do is find out what error number this is. It should be displayed on the error
message you're getting that you don't like. Or you can press Help to find the err.number. I'll
use x in the procedure below.

Strange case is that there was no err.number displayed.
I was able to find the Err number. It was 2116. With code like:
Private Sub Form_Error(Data Err As Integer, Response As Integer)
Select Case DataErr
Case 0
Case Else
MsgBox DataErr
End Select
End sub

Now the code is like:
Private Sub Form_Error(Data Err As Integer, Response As Integer)
Select Case DataErr
Case 2116 'Unneeded Access-warning
Response = acDataErrContin ue
Case Else
Response = acDataErrDispla y
End Select
End Sub

Problem is 'solved' now but ...
I still don't understand why Access comes up with this error in the first place ...
There is NO validation set in the table, no validation in the fields, no validation in the form.
I was thinking about corruption ? (already tried /decompile)


Try compact & repair.

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)
Nov 13 '05 #5
Arno R wrote:
Strange case is that there was no err.number displayed.
I was able to find the Err number. It was 2116. With code like:
Private Sub Form_Error(Data Err As Integer, Response As Integer)
Select Case DataErr
Case 0
Case Else
MsgBox DataErr
End Select
End sub
Yes, I do this myself sometimes and should have suggested it, but you
were able to figure it out! 8)
I still don't understand why Access comes up with this error in the first place ...
There is NO validation set in the table, no validation in the fields, no validation in the form.
I was thinking about corruption ? (already tried /decompile)


Are there any relationships anywhere that could be coming into play?

What about the data type that ends up going into the field? I've
sometimes had weird things happen because I'd forgotten exactly what the
data type of the field in the table was! Acutally, this happens to me
more times than I'm comfortable admitting, especially wiuth projects
that take a long time... 8)

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #6
Thanks again both Tim and MGFoster

Of course I tried compact & repair first, but to no avail.

I am using Access 2000 with SP3
I will check if the same issue is the case at the clients-side (Access XP).

Arno R

Nov 13 '05 #7

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

Similar topics

3
12522
by: Christopher Koh | last post by:
how do you stop Access from saving any changed data in your tables and queries? like i just add or change data on the table/query tables,then click on X (exit)because i have no intention of saving it but access still automatically saves it even if I did not press the save command on the menu/toolbar? What is the solution for this? help thanks!
1
15972
by: WindAndWaves | last post by:
Goodmorning Gurus Here is another of my questions..... When adding code to a control then access sometimes puts in a couple of 'parameters'. Can anyone tell me what the use of them is. I have never used them, but I would be keen to do so. Here is an example for a control (on a form) called CNW, when I add some code for the BeforeUpdate event, access puts in the following lines. Private Sub CNW_BeforeUpdate(******Cancel As...
3
1564
by: Rebecca Smith | last post by:
I’ve been using the code below in Access 97 for years now without any problems at all. Unfortunately, I now have to convert this db to Access 2000. I tried using the conversion feature and that was a bust. All my reports, queries and other forms work OK except for this routine. The first hang-up begins with the “dbOpenSanpshot” – does this exist in 2000? Also when I type “rstPatient” the “FindFirst” isn’t a method available to me nor is...
6
1785
by: David Sullivan | last post by:
Hi I have a problem with a database where certain users are closing access (by clicking on the X in top right-hand corner) instead of using a command button before they fill in all relevant fields. Q. Is there a way of not allowing them to exist access using the this way and use the command button? Thanks in Advance
0
1924
by: Privacy Trap | last post by:
Hi I have a slight problem in trying to set up 2 forms linked to tables. What I want to do is to inform a control on one form(Apps) as to the value of a key of a 'new' record entered via a second(Clients) In opening the second form I set up certian fields and controls on it from the first. In doing so however this seemingly creates a headache in coding for a situation where a user wants to abandon
3
6366
by: Oenone | last post by:
I'm writing an application with various MDI child forms. In the Closing event of many of the forms, I have code that asks the user whether he is sure he wants to close the form, because it contains unsaved data. If the user clicks "No" then the code sets e.Cancel = True, which cancels the closure. This works just great. But when the user closes the MDI parent form, the cancellation seems to be completely ignored. The MessageBox...
1
4077
by: Phill W. | last post by:
Has any come across a situation where, in a Form-derived .. er .. Form, the Event Arguments passed to OnClosing /already/ have their Cancel argument set to True? Protected Overrides Sub OnClosing( _ ByVal e As System.ComponentModel.CancelEventArgs _ ) Debug.WriteLine("e.Cancel=(" & e.Cancel.ToString() & ")") ' It's True already !!
3
7647
by: Smithers | last post by:
In consideration of the brief sample code at the following link... http://msdn2.microsoft.com/en-us/library/system.componentmodel.canceleventargs.cancel.aspx .... when we set e.Cancel = true, How does the form subsequently know to NOT close the form? More generally, after an event is raised, does the event raising class somehow retain a reference to the CancelEventArgs instance, and then check the value of the .Cancel property to...
5
8895
by: Steve | last post by:
In VB6 I have a screen the has a text box and a datagrid If I click the datagrid, the 1st event is to validate the textbox and then the 2nd event is a datagrid mousedown event. If a get an error message in the textbox validate it seems the mousedown event is never executed. In VB.Net it executes the textbox validation and then displays the error, but still executes the mousedown event. It appears that I have to explicitly...
3
11966
by: slenish | last post by:
Hello everyone, Well I am having a small problem with canceling an action and keeping the focus on the text box with the problem. To give some details as to what im trying to do. What i have is a form where I have an error box pop up if you are going to duplicate a record on the table. I have the event in the BeforeUpdate of the text box. So if there is a duplication (cancel = true). Now from everything I have been reading if you have...
0
8427
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
8850
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
8746
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
8523
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
8626
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
7355
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
4175
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
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1737
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.