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?
11 7329
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 - Private Sub Form_Error(DataErr As Integer, Response As Integer)
-
MsgBox "You Daft Bugger - you cocked that up well and truly!"
-
Response = acDataErrContinue
-
End Sub
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: - Private Sub Form_Error(DataErr As Integer, Response As Integer)
-
Const conINPUT_MASK_VIOLATION As Integer = 2297
-
-
If DataErr = conINPUT_MASK_VIOLATION Then
-
MsgBox "<your customized error message here>", vbExclamation, "Input Mask Violation"
-
Response = acDataErrContionue
-
End If
-
End Sub
NeoPa 32,556
Expert Mod 16PB - ...
-
MsgBox "You Daft Bugger - you cocked that up well and truly!"
-
...
or words to that effect :D
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?
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 - Private Sub Form_Error(DataErr As Integer, Response As Integer)
-
MsgBox "You Daft Bugger - you cocked that up well and truly!"
-
Response = acDataErrContinue
-
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.
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?
- 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: - Private Sub Form_Error(DataErr As Integer, Response As Integer)
-
Const conINPUT_MASK_VIOLATION As Integer = 2297
-
Const conREFERENTIAL_INTEGRITY_VIOLATION As Integer = 9999
-
Const conNO_DUPLICATES_ALLOWED_ON_THIS_FIELD As Integer = 8765
-
Const conRECORD_LOCKED_BY_ANOTHER_USER = 5555
-
-
Select Case DataErr
-
Case conINPUT_MASK_VIOLATION
-
MsgBox "<your customized error message here>
-
Response = acDataErrContinue
-
Case conREFERENTIAL_INTEGRITY_VIOLATION
-
MsgBox "<your customized error message here>
-
Response = acDataErrContinue
-
Case conNO_DUPLICATES_ALLOWED_ON_THIS_FIELD
-
MsgBox "<your customized error message here>
-
Response = acDataErrContinue
-
Case conRECORD_LOCKED_BY_ANOTHER_USER
-
MsgBox "<your customized error message here>
-
Response = acDataErrContinue
-
Case Else 'all other Errors, let Access handle them with
-
'its own Error Message
-
End If
-
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.
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.
- 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.
NeoPa 32,556
Expert Mod 16PB
No problem :)
Let us know how you get on or if you hit any difficulties.
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
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
| |