By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,374 Members | 2,993 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,374 IT Pros & Developers. It's quick & easy.

MAccess form error creation

P: n/a
I am creating a form that a person enters a date span in yyyymm form.
I want a box to pop up that tells the user "Please enter date in
correct format" if the user has entered the data incorrect. I have
entered the input mask and the auto tab order. I have done this
before, but I cannot remember the syntax for the code to pop up the
error box. Please help.
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The MsgBox statement displays a MessageBox. If you want a response, use the
MsgBox function. The operands/arguments determine the "severity" and the
possible responses.

Larry Linson
Microsoft Access MVP

"Jeremy" <jc*******@rmhp.org> wrote in message
news:e9**************************@posting.google.c om...
I am creating a form that a person enters a date span in yyyymm form.
I want a box to pop up that tells the user "Please enter date in
correct format" if the user has entered the data incorrect. I have
entered the input mask and the auto tab order. I have done this
before, but I cannot remember the syntax for the code to pop up the
error box. Please help.

Nov 12 '05 #2

P: n/a
If I understand you correctly, the InputMask in not needed, instead use a
Format of yyyy"/"mm
It should automatically change to yyy\/mm

Goto the Events tab of the form and choose [Event Proceedure] as the setting
for the OnError event. Click the builder button beside this and put in the
following...

Select Case DataErr
Case 2113 '----The value you entered isn't valid for this field...error
If Screen.ActiveControl = Me!Text0 Then
MsgBox "Please enter only valid Date information in the form of
yyyy/mm.", vbOKOnly, "Invalid Date"
Response = acDataErrContinue
End If
Case Else
Response = acDataErrDisplay
End Select

This should allow you to trap most errors and determine what control
triggered it. Add a new CASE section for each form error you wish to trap,
and use Screen.ActiveControl to tailor the process according to the control
that caused it.

Mike Storr

PS - I based this assuming you are working in A97, but I'm pretty sure this
should still apply in 2K
"Jeremy" <jc*******@rmhp.org> wrote in message
news:e9**************************@posting.google.c om...
I am creating a form that a person enters a date span in yyyymm form.
I want a box to pop up that tells the user "Please enter date in
correct format" if the user has entered the data incorrect. I have
entered the input mask and the auto tab order. I have done this
before, but I cannot remember the syntax for the code to pop up the
error box. Please help.

Nov 12 '05 #3

P: n/a
jc*******@rmhp.org (Jeremy) wrote in message news:<e9**************************@posting.google. com>...
I am creating a form that a person enters a date span in yyyymm form.
I want a box to pop up that tells the user "Please enter date in
correct format" if the user has entered the data incorrect. I have
entered the input mask and the auto tab order. I have done this
before, but I cannot remember the syntax for the code to pop up the
error box. Please help.


OnExit of field...
If not IsDate(MyField) then
msgbox "Date should be in <whatever> format", vbokonly, "Wrong date format"
Me.MyDateField.Setfocus
End If

Or something like that...
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.