Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Posts a Message Before I Do! 1

Status
Not open for further replies.

TheAceMan1

Programmer
Sep 23, 2003
11,174
US
Howdy All ...

In 2003, performing some validation on a date textbox control with the following code:

Code:
[blue]Private Sub vacDate_BeforeUpdate(Cancel As Integer)
   
   If Not IsDate(Me.vacDate) Then
      Cancel = True
      
      Msg = "An UnRecognized Date has been entered!@" & DL & _
            "Fix it or hit the 'Esc' Key@"
      Style = vbCritical + vbOKOnly
      Title = "Definitely a Bad 'Date' ..."
      Call uMsg
   End If
   
End Sub[/blue]

The code works, however during testing (entering erroneous date) microsoft throws up the following message 1st:

Microsoft said:
[blue]The value you entered isn't valid for this field.

For example you may have entered text in a numeric field or a number larger than the field size setting permits.[/blue]

... my message comes after.

Anyone know whats going on here? Is there a fix?

Many thanks in advance ...

See Ya . . .

Be sure to see FAQ219-2884 Worthy Reading! [thumbsup2]
Also FAQ181-2886 Worthy Reading! [thumbsup2]
 
Do you have any (custom) Mask on your vacDate?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Andrzejek ...

No. Not a one ... not in the control or the table.

See Ya . . .

Be sure to see FAQ219-2884 Worthy Reading! [thumbsup2]
Also FAQ181-2886 Worthy Reading! [thumbsup2]
 
see the form error event. This is a data error and not a run time error. Also the Form error event happens before the before update.
something like this
Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
   If DataErr = 2113 Then
     If Me.ActiveControl.Name = "vacdate" Then
       Response = acDataErrContinue
       MsgBox "An UnRecognized Date has been entered!@" & vbCrLf & "Fix it or hit the 'Esc' Ke"
     End If
   End If
End Sub
The Error event occurs when a run-time error is produced in Microsoft Access when a form has the focus.
Syntax
expression .Error(DataErr, Response)
expression A variable that represents a Form object.
Parameters
Name
Required/Optional
Data Type
Description
DataErr
Required
Integer
The error code returned by the Err object when an error occurs. You can use the DataErr argument with the Error function to map the number to the corresponding error message.
Response
Required
Integer
The setting determines whether or not an error message is displayed. The Response argument can be one of the following intrinsic constants.
acDataErrContinue Ignore the error and continue without displaying the default Microsoft Access error message. You can supply a custom error message in place of the default error message.
acDataErrDisplay (Default) Display the default Microsoft Access error message.
Remarks
This includes Microsoft Access database engine errors, but not run-time errors in Visual Basic or errors from ADO.
To run a macro or event procedure when this event occurs, set the OnError property to the name of the macro or to [Event Procedure].
By running an event procedure or a macro when an Error event occurs, you can intercept a Microsoft Access error message and display a custom message that conveys a more specific meaning for your application.
 
Howdy MajP . . .

Forgot all about that ... [blue]thanks for the wakeup![/blue]

See Ya . . .

Be sure to see FAQ219-2884 Worthy Reading! [thumbsup2]
Also FAQ181-2886 Worthy Reading! [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top