Question 1: I am using an input mask to make sure that the correct format is used in a textbox. When there is an error, the message box that comes up shows what the input mask is and that what was typed is wrong. Is there a way to change what is in this message box?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
InputMask Message??? (Access 97)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » InputMask Message??? (Access 97)
- This topic has 7 replies, 4 voices, and was last updated 22 years, 11 months ago.
Viewing 0 reply threadsAuthorReplies-
WSHansV
AskWoody LoungerJune 12, 2002 at 2:36 pm #594169You can use the OnError event of the form to handle errors. An input mask error has error number 2279.
In design view of the form, make sure the form itself is selected.
In the Properties window, select the Events tab.
Near the end of the list, you’ll find the Error event.
Use it to create an error handler and enter the following code:Private Sub Form_Error(DataErr As Integer, Response As Integer)
Select Case DataErr
Case 2279
‘ Input mask error – display our own error message
MsgBox “Correct your entry or else…”, vbExclamation
‘ And tell Access not to display its own message
Response = acDataErrContinue
‘ Add other special cases here
‘…
‘ Otherwise, display standard error message
Case Else
Response = acDataErrDisplay
End Select
End Sub -
WSSupport4John
AskWoody Lounger -
WSHansV
AskWoody Lounger -
WSSupport4John
AskWoody LoungerJune 13, 2002 at 11:14 am #594458Hi Hans
I was missing err 2113, following is your of several weeks ago with 2113 added, works great.
Thank, John
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Const INPUTMASK_VIOLATION = 2279 ‘ permit no, phone, ss no,
Const FIELD_VIOLATION = 2113 ‘ date and time
Dim Msg As String
If DataErr = INPUTMASK_VIOLATION Or DataErr = FIELD_VIOLATION Then
Select Case Screen.ActiveControl.NameCase “strPermitNo”
Beep
MsgBox “The Registration Number you entered is invalid!” _
& vbLf & vbLf & vbCr & _
“Enter it properly as follows:” _
& vbLf & vbLf & vbCr & _
” 2002-00001″ & vbLf & vbCr & _
” ^ ^” & vbLf & vbCr & _
” | |” & vbLf & vbCr & _
” | —– Record Number (5 digits)” & vbLf & vbCr & _
” | ” & vbLf & vbCr & _
” —– Year (4 digits)” & vbLf & vbLf & vbCr & _
“Press Esc Key to twice to restore the original field value.”Case “strPhone”, “strHomePhone”, “strWorkPhone”, “strBuilderPhone”, _
“strBuilderCellPhone”
Beep
MsgBox “The Phone Number you entered is invalid!” _
& vbLf & vbLf & vbCr & _
“Either enter it properly as follows, or leave it blank.” _
& vbLf & vbLf & vbCr & _
” (716) 754-8797″ _
& vbLf & vbCr & _
” ( ) 754-8797 (space bar 3 times to bypass area code)” _
& vbLf & vbLf & vbCr & _
“Press Esc Key to twice to restore the original field value.”Case “dtmInspectionTime”
Beep
MsgBox “The Time you entered is invalid!” _
& vbLf & vbLf & vbCr & _
“Enter it properly as follows:” _
& vbLf & vbLf & vbCr & _
” hh:mm ” & vbLf & vbCr & _
” hh:mma” & vbLf & vbCr & _
” hh:mmp” & vbLf & vbLf & vbCr & _
“Press Esc Key to twice to restore the original field value.”Case “dtmReceiveDate”, “dtmIssueDate”, “dtmExpireDate”, _
“dtmCORenewalDate”, “dtmTmpCOExpDate”, “dtmInsExpDate”
Beep
MsgBox “The Date you entered is invalid!” _
& vbLf & vbLf & vbCr & _
“Enter it properly as follows:” _
& vbLf & vbLf & vbCr & _
” m/d/y ” & vbLf & vbCr & _
” mm/dd/yy” & vbLf & vbCr & _
” mm/dd/yyyy” & vbLf & vbLf & vbCr & _
“Press Esc Key to twice to restore the original field value.”Case Else
Beep
Msg = “An input mask violation occurred in control ”
MsgBox Msg & Screen.ActiveControl.Name & “!”
End Select
Response = acDataErrContinue
End IfEnd Sub
-
-
-
WSLu1219
AskWoody Lounger -
WSaccdb
AskWoody Lounger -
WSHansV
AskWoody LoungerJune 13, 2002 at 5:04 am #594378Accdb already answered your first question.
About the second one (specific error messages): when the error occurs, the offending text box is the ActiveControl. You can use the properties of this control (Name, InputMask, ControlSource, …) to create a specific message. Here is an example. Of course, the possible variations are endless.
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim strMessage As String
Select Case DataErr
Case 2279
Select Case ActiveControl
Case txtTextEntry1, txtTextEntry2
strMessage = “Please enter an alphabetic string of exactly 5 characters.”
Case txtNumericEntry1
strMessage = “Please conform to the input mask ” & ActiveControl.InputMask
Case txtNumericEntry2
strMessage = “This is not a valid entry for ” & ActiveControl.ControlSource
End Select
MsgBox strMessage, vbExclamation
Response = acDataErrContinue
Case Else
Response = acDataErrDisplay
End Select
End Sub
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Outdated Laptop
by
jdamkeene
3 hours, 7 minutes ago -
Updating Keepass2Android
by
CBFPD-Chief115
8 hours, 32 minutes ago -
Another big Microsoft layoff
by
Charlie
8 hours, 12 minutes ago -
PowerShell to detect NPU – Testers Needed
by
RetiredGeek
8 hours ago -
May 2025 updates are out
by
Susan Bradley
8 hours, 36 minutes ago -
Windows 11 Insider Preview build 26200.5600 released to DEV
by
joep517
14 hours, 15 minutes ago -
Windows 11 Insider Preview build 26120.3964 (24H2) released to BETA
by
joep517
14 hours, 17 minutes ago -
Drivers suggested via Windows Update
by
Tex265
14 hours, 8 minutes ago -
Thunderbird release notes for 128 esr have disappeared
by
EricB
11 hours, 52 minutes ago -
CISA mutes own website, shifts routine cyber alerts to X, RSS, email
by
Nibbled To Death By Ducks
21 hours, 8 minutes ago -
Apple releases 18.5
by
Susan Bradley
15 hours, 33 minutes ago -
Fedora Linux 40 will go end of life for updates and support on 2025-05-13.
by
Alex5723
22 hours, 34 minutes ago -
How a new type of AI is helping police skirt facial recognition bans
by
Alex5723
23 hours, 11 minutes ago -
Windows 7 ISO /Windows 10 ISO
by
ECWS
6 hours, 27 minutes ago -
No HP software folders
by
fpefpe
1 day, 6 hours ago -
Which antivirus apps and VPNs are the most secure in 2025?
by
B. Livingston
4 hours, 12 minutes ago -
Stay connected anywhere
by
Peter Deegan
1 day, 12 hours ago -
Copilot, under the table
by
Will Fastie
1 day, 3 hours ago -
The Windows experience
by
Will Fastie
1 day, 18 hours ago -
A tale of two operating systems
by
Susan Bradley
5 minutes ago -
Microsoft : Resolving Blue Screen errors in Windows
by
Alex5723
1 day, 23 hours ago -
Where’s the cache today?
by
Up2you2
2 days, 15 hours ago -
Ascension says recent data breach affects over 430,000 patients
by
Nibbled To Death By Ducks
2 days, 7 hours ago -
Nintendo Switch 2 has a remote killing switch
by
Alex5723
1 day, 8 hours ago -
Blocking Search (on task bar) from going to web
by
HenryW
10 hours, 29 minutes ago -
Windows 10: Microsoft 365 Apps will be supported up to Oct. 10 2028
by
Alex5723
3 days, 8 hours ago -
Add or Remove “Ask Copilot” Context Menu in Windows 11 and 10
by
Alex5723
3 days, 8 hours ago -
regarding april update and may update
by
heybengbeng
3 days, 10 hours ago -
MS Passkey
by
pmruzicka
2 days, 11 hours ago -
Can’t make Opera my default browser
by
bmeacham
3 days, 17 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.