473,320 Members | 1,799 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.

Access Input Mask error messages

blyxx86
256 100+
Is there some code that I can use to change the error message a user gets when they input an invalid entry for an input mask.

Instead of it being technical jargon, I'd like the user to get a generic message saying that they entered the incorrect information for [Field1].

How do I go about doing this?
Apr 23 '07 #1
11 7329
pks00
280 Expert 100+
The form has a event handler called On Error
basically u use that to add in your own error messages

You need to set the Response as well otherwise default msg still appears
eg

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2.     MsgBox "You Daft Bugger - you cocked that up well and truly!"
  3.     Response = acDataErrContinue
  4. End Sub
Apr 26 '07 #2
ADezii
8,834 Expert 8TB
Is there some code that I can use to change the error message a user gets when they input an invalid entry for an input mask.

Instead of it being technical jargon, I'd like the user to get a generic message saying that they entered the incorrect information for [Field1].

How do I go about doing this?
Place the following code in your Form's Error() Event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2.   Const conINPUT_MASK_VIOLATION As Integer = 2297
  3.  
  4.   If DataErr = conINPUT_MASK_VIOLATION Then
  5.     MsgBox "<your customized error message here>", vbExclamation, "Input Mask Violation"
  6.     Response = acDataErrContionue
  7.   End If
  8. End Sub
Apr 26 '07 #3
NeoPa
32,556 Expert Mod 16PB
Expand|Select|Wrap|Line Numbers
  1. ...
  2. MsgBox "You Daft Bugger - you cocked that up well and truly!"
  3. ...
or words to that effect :D
Apr 26 '07 #4
blyxx86
256 100+
Alright, I see this (sorry it has taken so long to reply).. Thank you!

Now to further complicate the matter just a bit... or simplify, I'm not sure which is right (going on the past week with a little over 8 hours of sleep total)...

With the integer, that is the error code, correct? Would I then be able to customize the errors for other various events like "Duplicate primary keys" and such? I would just have to find the integer of the error code?

If that is true, then (in simple terms, I do not need a vast explanation) how would I place those newly created error message in a public module instead of on each instance of a form?
Apr 27 '07 #5
blyxx86
256 100+
The form has a event handler called On Error
basically u use that to add in your own error messages

You need to set the Response as well otherwise default msg still appears
eg

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2.     MsgBox "You Daft Bugger - you cocked that up well and truly!"
  3.     Response = acDataErrContinue
  4. End Sub
Precisely the message I want to get across, sadly most of the employers where I work won't quite understand that form of English... Perhaps I'll place that in there anyways.. it's still technically in beta form. I can modify it later.
Apr 27 '07 #6
ADezii
8,834 Expert 8TB
Alright, I see this (sorry it has taken so long to reply).. Thank you!

Now to further complicate the matter just a bit... or simplify, I'm not sure which is right (going on the past week with a little over 8 hours of sleep total)...

With the integer, that is the error code, correct? Would I then be able to customize the errors for other various events like "Duplicate primary keys" and such? I would just have to find the integer of the error code?

If that is true, then (in simple terms, I do not need a vast explanation) how would I place those newly created error message in a public module instead of on each instance of a form?
Expand|Select|Wrap|Line Numbers
  1. With the integer, that is the error code, correct?
Yes
Would I then be able to customize the errors for other various events like "Duplicate primary keys" and such?
Yes, with similiar code below to that posted below:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2.   Const conINPUT_MASK_VIOLATION As Integer = 2297
  3.   Const conREFERENTIAL_INTEGRITY_VIOLATION As Integer = 9999
  4.   Const conNO_DUPLICATES_ALLOWED_ON_THIS_FIELD As Integer = 8765
  5.   Const conRECORD_LOCKED_BY_ANOTHER_USER = 5555
  6.  
  7.   Select Case DataErr
  8.      Case conINPUT_MASK_VIOLATION 
  9.        MsgBox "<your customized error message here>
  10.           Response = acDataErrContinue
  11.     Case conREFERENTIAL_INTEGRITY_VIOLATION
  12.        MsgBox "<your customized error message here>
  13.           Response = acDataErrContinue 
  14.     Case conNO_DUPLICATES_ALLOWED_ON_THIS_FIELD
  15.        MsgBox "<your customized error message here>
  16.           Response = acDataErrContinue
  17.     Case conRECORD_LOCKED_BY_ANOTHER_USER
  18.         MsgBox "<your customized error message here>
  19.           Response = acDataErrContinue
  20.     Case Else     'all other Errors, let Access handle them with
  21.                         'its own Error Message  
  22.   End If
  23. End Sub
I would just have to find the integer of the error code?
No, that value is already present in DataErr.

NOTE: Error Constants and values are for demonstration purposes only and are not actual values.
Apr 27 '07 #7
NeoPa
32,556 Expert Mod 16PB
If that is true, then (in simple terms, I do not need a vast explanation) how would I place those newly created error message in a public module instead of on each instance of a form?
  • Create a public procedure in a standard (not form; report; class; etc) module.
  • Set it up so that it can handle any parameters you need.
  • Create a big 'Select Case' statement that handles all the error types you want.
  • Call this procedure from any form where you want this standard handling of errors.
Apr 27 '07 #8
blyxx86
256 100+
  • Create a public procedure in a standard (not form; report; class; etc) module.
  • Set it up so that it can handle any parameters you need.
  • Create a big 'Select Case' statement that handles all the error types you want.
  • Call this procedure from any form where you want this standard handling of errors.
Thank you! I shall attempt to do something similar.
May 1 '07 #9
NeoPa
32,556 Expert Mod 16PB
No problem :)
Let us know how you get on or if you hit any difficulties.
May 1 '07 #10
xpun
39
im having the same problem however i have multiple fields i want to check this for
i put that code in the form error handle but it dosent work
May 14 '07 #11
NeoPa
32,556 Expert Mod 16PB
So when you create your thread to explain your problem, say what you've attempted so far and which bit(s) don't work.
Some punctuation will be expected too, if you expect anyone to respond to your issue.

MODERATOR.
May 15 '07 #12

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

Similar topics

4
by: David W. Fenton | last post by:
I'm working on a subform where users put in 24-hour time. On their paper forms, they've been accustomed to referring to midnight as 24:00 (instead of as 0:00, which kind of makes sense from a human...
9
by: Paul | last post by:
hi, is there an input mask i could use on a report to do the following: (1) if i enter "THISISATEST" on my form, i want the text box on my report to display: "T H I S I S A T E S T". (2) if...
2
by: Paul | last post by:
Hi everyone, here is the problem: I have 2 fields...Province and PostalCode The afterUpdate event of the province has this snippet of code: ... ... If Country = "canada" Then...
3
by: John Williams | last post by:
I'm writing a stagenography program to experiment with how it works. The algorithm I'm using appears to be producing the correct result...however I'm struggling with the file input. I never...
1
by: saddist | last post by:
Hello, I've been working on access 2000 for few days. I made some forms with textfields where you can type date. Those textfields had input mask set for short date 99/99/0000. Now software have...
9
by: Ron | last post by:
Hi All, I've recently installed a program written in Access 2000 on a laptop. The laptop had an existing Office 2000 Pro which of course included Access. But the program acts oddly (more oddly...
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...
3
by: Guig | last post by:
Hi, I have a problem with one of my form. I want to record some data in a table by using a form. One of those data it is the time and I want to use an input mask to be sure that everyone will...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
1
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
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
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.