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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

returning a field to its original value 1

Status
Not open for further replies.

mattl72

IS-IT--Management
Oct 2, 2002
24
0
0
US
Hi

Okay, I know (hope) this is probably relatively easy to do but I'm having trouble with it.

I have a main form with subform in a datasheet view that tracks inventory information. In the afterupdate event of the subform, I have a routine that checks to see if a condition is true. If it is, I would like to undo the changes that were just made that caused the condition. So for example, if a user tries to check more than one primary bin, I would like to have it display an error (I have this part done) and return the value to its original value. I tried the undo command and it didn't seem to work.

I hope I am making sense here. Thanks for any help

Matt L
 
You need to use the BeforeUpdate() event and make sure to Cancel the event as well as Undo it:
Code:
Private Sub txtName_BeforeUpdate(Cancel As Integer)
  If Len(txtName) > 4 Then
    MsgBox "Too many letters"
    txtName.Undo
    Cancel = True
  End If
End Sub

VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top