BeforeUpdate Undo

J

Jim Franklin

Hi,

I have a combo box bound to a field which has its Required property set to
true. The control has code in its BeforeUpdate event to check that if
certain values are selected, other criteria have been satisfied - if not I
want to cancel the event and undo the selection made.

The cancel event works fine, but if I try to undo the control when entering
a new record, Access pops up with a validation rule violation message and
does not undo the control.

Any simple way round this anyone?

Thanks,

Jim F.
 
J

Jim Franklin

Hi Allen,

Thanks for your reply. I have tried this - the only problem I found was that
using the Undo command in the AfterUpdate event didn't seem to do anything
to the data in the control. Using the sample bit of code below, the message
appears, but the StartDate does not get reset.

Private Sub STARTDATE_AfterUpdate()

If me!ENDDATE < me!STARTDATE Then
MsgBox "The Start Date cannot be later than the End Date"
Me!STARTDATE.Undo
End If

End Sub

Any ideas?

Jim F.
 
A

Allen Browne

Hmm: it should undo it.

Is the record still dirty at this time, or has it already been saved?

What happens if you assign the control's OldValue to it:
Me.STARTDATE = Me.STARTDATE.OldVale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top