Before update event Access Message?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi new to access but keen. I have a cmd button on a form that is initiating a
forced save Me.dirty = False. I think this is firing the before Update event
that I am validating data entry with. Code

If DateDiff("n", StartTime, FinishTime) <= 0 Then
Cancel = True
MsgBox "You cannot end the task before you start!", vbOKOnly, "Review
your start and finish times!"
Me.FinishTime.SetFocus
Exit Sub
End If

This seems to be working as the message box appears but then another
meassage from Access apears saying "The setting you entered is invalid for
the property" on clicking ok the focus moves to Finish Time.

How do I get rid of this message and what does it mean? I am using Access
2003. Any help would be greatly appreciated.
 
QldSandy said:
Hi new to access but keen. I have a cmd button on a form that is initiating a
forced save Me.dirty = False. I think this is firing the before Update event
that I am validating data entry with. Code

If DateDiff("n", StartTime, FinishTime) <= 0 Then
Cancel = True
MsgBox "You cannot end the task before you start!", vbOKOnly, "Review
your start and finish times!"
Me.FinishTime.SetFocus
Exit Sub
End If

This seems to be working as the message box appears but then another
meassage from Access apears saying "The setting you entered is invalid for
the property" on clicking ok the focus moves to Finish Time.

How do I get rid of this message and what does it mean? I am using Access
2003.


I think you can avoid the situation by checking the date
values (in the button's code) before trying to save the
record.

Or, the button's code can trap the error and ignore it if
its the expected error number. Don't know what error
handling code you have, but something like this might do it.

On Error GoTo ErrHandler
. . .
Me.dirty = False
. . .
ExitHere:
Exit Sub

ErrHandler:
Select Case Err.Number
Case ??
Resume ExitHere
Case Else
ErrMsg Err.Number & " - " & Err.Description
Resume ExitHere
End Select
End Sub
 
Back
Top