before Update event

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
 
M

Marshall Barton

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).
 

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