before Update event

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

In a control's beforeUpdate event I have the following code:

Public Sub PartyIDTo_BeforeUpdate(Cancel As Integer)
On Error GoTo Error_Handler

'if user is selecting a new party for a fax
'previously sent, chances are they are trying
'to send a new fax
If Nz(Me.ContactStatusID, 0) = gcSent Then
If MsgBox("New Fax? ", vbYesNo) = vbYes Then
NewContactParty
Else
MsgBox "This Fax has been sent and" & _
" cannot be edited."
Cancel = True
Me!PartyIDTo.Undo
End If
End If

The problem is that in the "Else" clause, this code does not role back the
value the user entered. The control is unbound. Why is the undo not working?
Thanks so much.

Sam
 
Sam said:
In a control's beforeUpdate event I have the following code:

Public Sub PartyIDTo_BeforeUpdate(Cancel As Integer)
On Error GoTo Error_Handler

'if user is selecting a new party for a fax
'previously sent, chances are they are trying
'to send a new fax
If Nz(Me.ContactStatusID, 0) = gcSent Then
If MsgBox("New Fax? ", vbYesNo) = vbYes Then
NewContactParty
Else
MsgBox "This Fax has been sent and" & _
" cannot be edited."
Cancel = True
Me!PartyIDTo.Undo
End If
End If

The problem is that in the "Else" clause, this code does not role back the
value the user entered. The control is unbound. Why is the undo not working?


An unbound control has no record where Access can go to get
a previous value. Besides, you either know what value it
had when the form opened (Null) or you can use code to save
a previously entered value before a user changes it (use the
Enter event to save it to a module level variable).
 
Back
Top