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

Home Posts Topics Members FAQ

Supress 2nd Validation Error

1,287 Recognized Expert Top Contributor
I have a text box with a validation rule and validation text. When entering a new record, if I put in invalid text, the validation text is displayed in a message box, but after clicking OK, another message box is displayed with:
-----------
myApplication (i bubble icon)
The value violates the validation rule for the field or record.

For example, you might have changed a validation rule without verifying whether the existing data matches the new validation rule.

Click undo to restore the previous value, or enter a new value that meets the validation rule for the field or records.
[OK] [Help]
-----------
After clicking OK here, if I try to tab out of the text box without changing anything, I get only the validation text message. So this 2nd message only happens the first time an entry is invalid. I've tried using the Form_Error event and DataErr 7753, but I still get this extra message. The table has no restrictions on the text field. Any idea how I can suppress this?

I just noticed that if I press Escape after the closing validation text message box, it saves the record with the invalid data! What am I doing wrong?
Feb 23 '09 #1
18 6216
RuralGuy
375 Recognized Expert Contributor
I personally do not use the validation available in a table but put it *all* in the BeforeUpdate event of the control for the field in the form and the BeforeUpdate event of the DataEntry/Edit form. Just my $0.02. I feel it gives me more control over the messages.
Feb 24 '09 #2
ChipR
1,287 Recognized Expert Top Contributor
Thanks, I'll give that a try. If I put some testing code and message box in the BeforeUpdate even of the control, what do I need to put in the BeforeUpdate event of the form? I hope this isn't a dumb question, I'm just not sure exactly of the sequence of events with the BeforeUpdate.
Feb 24 '09 #3
RuralGuy
375 Recognized Expert Contributor
I use the BeforeUpdate event of the form to check for missing entries.
Feb 24 '09 #4
ChipR
1,287 Recognized Expert Top Contributor
Ah, that would allow you to deal with any fields that can't be null before you get a stupid error message from Acess. I get it :)
Feb 24 '09 #5
ChipR
1,287 Recognized Expert Top Contributor
Ok, I like using the BeforeUpdate very much, but I'm still getting this 2nd error message. Here's the code for my text box.

Expand|Select|Wrap|Line Numbers
  1. Private Sub TimeIn_BeforeUpdate(Cancel As Integer)
  2.     'MsgBox "before time in update"
  3.     If IsNull(TimeIn) Then
  4.         Cancel = True
  5.         Exit Sub
  6.     End If
  7.     'check for valid time
  8.     If TimeIn > 2359 Or TimeIn Mod 100 > 59 Then
  9.         MsgBox "Please enter a 4-digit military time, or press Escape to cancel."
  10.         Cancel = True
  11.         Exit Sub
  12.     End If
  13.     If IsNull([TimeOut]) Then
  14.         Exit Sub
  15.     End If
  16.     'check < TimeOut
  17.     If TimeIn >= TimeOut Then
  18.         MsgBox "The time in must be before the time out."
  19.         Cancel = True
  20.     End If
  21. End Sub
I've removed the validation from the control, and the table never had any. The field is still a text type. Now, if I go to a new record and put in something like 2600, I get my MsgBox, then I still get this other Access message. The BeforeUpdate event of the form isn't called in this case.

The 2nd message is still only on the first error, but it happens in each field in a new record. So if I put something invalid in Time In the first time, I get 2 errors. Now I try to submit it again, I get one error. I fix it and go to the Time Out text box and put in something invalid, I get 2 errors. I try to submit it again, and I only get one error.

Is there any other way I can try to intercept this message?
Feb 24 '09 #6
ChipR
1,287 Recognized Expert Top Contributor
Well I finally found it.

Even though I'm cancelling in the control's BeforeUpdate Event, there is still a Form Error Event being triggered with a DataErr of 2116.

I haven't been able to find an explanation of why, and I'm surprised that others haven't experienced it, but at least I can stop it from bothering my users.
Feb 24 '09 #7
ChipR
1,287 Recognized Expert Top Contributor
Well, suppressing this error message hasn't solved the actual problem. My code above doesn't work, and I can't figure out why. When I enter an invalid value in a control the first time, it is not getting cancelled, it's getting saved. And that's why the form error is called. Can anyone tell me why the cancel isn't working?
Feb 24 '09 #8
RuralGuy
375 Recognized Expert Contributor
Setting Cancel = True in the BeforeUpdate event of a control holds the focus in that control. What version of Access are you using? There is a Service Pack for both ac2003 and ac2007 and HotFixes for both as well.
Feb 24 '09 #9
ChipR
1,287 Recognized Expert Top Contributor
I have 2007 and the latest service pack, but I don't see any hotfixes. I haven't found any that describe fixes for problems like mine though.

The focus is not actually leaving the control, as far as I can tell. I enter invalid data, and try to tab out of the field. I get the BeforeUpdate MsgBox and the Form Error, and the cursor remains in the same control, but the value has been saved. I can see this because if I hit Escape, the invalid value remains in the control, like it is reverting back to the previously saved value. But when the BeforeUpdate event is called, the control has no .OldValue. The .OldValue is still either null or empty when the Form Error occurs.

This is on a continuous form, but that shouldn't matter, should it?
Feb 25 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4520
by: LRW | last post by:
I'm creating a simple reply form, and if a form item isn't answered I get an error: "Notice: Undefined index: rb_amntspent in c:\inetpub\wwwroot\mackinaw\survey.php on line 36" even if in the code I allow for an unselected item. (Code at the bottom here.) It works fine otherwise. Now in the past I've made a change to php.ini to repress errors, but for this project I don't have access to the php.ini.
2
9449
by: Shone | last post by:
I would like to perform a 2-pass XML reading from a stream. Once using the Validating reader, just to confirm the validity against the schema, and next time to do a reading to extract the data. Actually, second time I do a deserialization, the data from XML is fed directly to an object. The problem I am experiencing is the error at the second reading attempt, and error description implies that reader is winded to the end of the XML and...
1
3535
by: David | last post by:
I have a custom control that contains a class that Inherits the panel control. I am trying to catch a keydown event in this class and then supress it from the rest of the control as well as the form that hosts the control. The problem I am running into is that the form that hosts the control will respond to the keydown event event. Any ideas what I am missing? Some source code to help:
14
6292
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2) show the error message next to the control. For example, if the text field is empty with RequiredField Validator control, it can show the value in ControlToValidate property in two ways as I mentioned. Please advise. Thanks!
2
3995
by: Martyn Fewtrell | last post by:
Dear All I have a Windows 2003 Server with IIS6 where the validation controls on ASP.Net pages no longer work. I believe it to be specific to the server as if I create an ASP.Net page on the IIS Server of my Workstation (Win XP) with a text box, button and required field validator, this works fine. If I create the same page on the IIS6 Windows 2003 Server the validation control doesn't stop the post. I've tried different browsers and...
12
2252
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation errors show up in your error-list, you can disable this functionality by selecting the Tools->Options menu item in VS or Visual Web Developer. Select the TextEditor->Html->Validation tree option in the left-hand side of the
9
4167
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be honest I usually hire someone to do it for me, grab predone scripts and kind of hack out the parts that I need, or just do very minimal validation (e.g. this is numeric, this is alpha-numeric, etc.)
11
2986
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether certain fields match certain criteria, and inform the user in different ways when the data is wrong (offcourse, this will be checked on posting the data again, but that's something I've got a lot of experience with). Now, offcourse it's...
2
1335
by: khani | last post by:
Hi i have following situation in cystal report in detail section i have a field say name.now i have five duplication record like this zahid zahid zahid zahid
0
8356
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
8871
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
8783
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...
0
8640
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
4198
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
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
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
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
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.