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

Answer creating a custom message box when the input mask in a field is not followed.

I finally came up with an answer for creating a custom message if the input mask is violated. In the properties window for the phone field, open the data tab. In the validation rule I typed in the code Is Null Or (Like "(???) ???-????") which includes making the field not to be required. In the validation text I typed in the custom error message, Please enter a number that is in a (999) 999-9999 format! This is triggered if there are too many or not enough numbers typed into the field.
Jul 31 '07 #1
3 2682
FishVal
2,653 Expert 2GB
I finally came up with an answer for creating a custom message if the input mask is violated. In the properties window for the phone field, open the data tab. In the validation rule I typed in the code Is Null Or (Like "(???) ???-????") which includes making the field not to be required. In the validation text I typed in the custom error message, Please enter a number that is in a (999) 999-9999 format! This is triggered if there are too many or not enough numbers typed into the field.
Depends on how do you enter data.

Via form: you can handle OnError event. The following code is very simple one, it displays the same message whenever mask input rules has been violated in any form control.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2.  
  3.     Const ercMaskViolation = 2279
  4.  
  5.     If DataErr = ercMaskViolation Then
  6.         MsgBox ("Your message here")
  7.         Response = acDataErrContinue
  8.     End If
  9.  
  10. End Sub
  11.  
Via table/query: I think Access doesn't allow to hook this situation.
Aug 1 '07 #2
I think this will only work if you try to close the form. If there is a form with a SAVE button and you try to save the form you will get a generic Access message which will over ride the custom message.


Depends on how do you enter data.

Via form: you can handle OnError event. The following code is very simple one, it displays the same message whenever mask input rules has been violated in any form control.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2.  
  3.     Const ercMaskViolation = 2279
  4.  
  5.     If DataErr = ercMaskViolation Then
  6.         MsgBox ("Your message here")
  7.         Response = acDataErrContinue
  8.     End If
  9.  
  10. End Sub
  11.  
Via table/query: I think Access doesn't allow to hook this situation.
Aug 4 '07 #3
FishVal
2,653 Expert 2GB
I think this will only work if you try to close the form. If there is a form with a SAVE button and you try to save the form you will get a generic Access message which will over ride the custom message.
Are you kidding me? ;)
Everything works fine, no matter whether a form is bound or unbound and with any quantity of "SAVE" buttons as well.
Has you set InputMask property for table field, for correspondent form control or for both 'em? Plz post the mask(s) text.
Aug 5 '07 #4

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

Similar topics

2
by: Ellen Manning | last post by:
I've got an A2K database with a link to a table in another A2K database. This linked table contains SSN formatted with the SSN input mask. I'm trying to use a dlookup using this linked table. ...
1
by: Bill Agee | last post by:
I would like to capture time with hh:mm:ss only without a PM/AM designation. When I create a custom date format specifying hh:mm:ss with a 00:00:00 input mask the system automatically fills in a...
2
by: Serious_Practitioner | last post by:
Hello, and thank you in advance for your help. Again. I want to enter the month and day portions only of a date into a table field. The idea is that I'll use the information later to generate a...
6
by: Regnab | last post by:
Morning All, I'm trying to ensure that when the user enters a number on a form, the database automatically leaves a space after the 3rd number. I've tried to do this using input masks, but when...
0
by: Jozef | last post by:
Hello, I have some code that is creating a new fields in a remote database. Is there any way to create an input mask on that new field with DAO 3.6? Thanks!
5
by: travellinman | last post by:
Hi, I'd like to make an input mask, based on another field's value. For example, if the value of the other field (in another table) is 125, then i want my input mask to start with 125, subsequently...
18
by: louie310 | last post by:
I am working on a Access data base as a school project. The data base has forms with fields that need to be filled out. The forms currently are set up where certain fields that are required have...
14
by: Trevor2007 | last post by:
I would like to allow the user to enter an input mask for a field and have the appropriate error message display if the citeria isn't met.ie: input mask = 99AA99"A""B" the message box would then...
39
by: jaad | last post by:
There are literally thousands and thousands of entry about this subject but still after 6 years of looking and researching I haven't found a simple answer to a really simple question: I have two...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.