473,839 Members | 1,461 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 6239
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
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
375 Recognized Expert Contributor
I use the BeforeUpdate event of the form to check for missing entries.
Feb 24 '09 #4
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
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
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
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
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
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

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.
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...
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:
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!
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...
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
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.)
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...
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
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,...
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...
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,...
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...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.