M
MBoozer
Trying to create a simple cancel code in case user gets crazy hitting
buttons. The code below works great EXCEPT that when user hits button a
"second" time, vberror message pops up saying command undo isn't availble and
asking to debug. Is my code too complex or is there something I can put in to
stop the error?
If Me.NewRecord And IsNull(Me.[SupplierName]) Then
DoCmd.CancelEvent
Me.Requery 'sets focus back to top of list
'when user hits add newrecord button but has not entered any data into field
ElseIf Me.NewRecord And Not IsNull(Me.[SupplierName]) Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.CancelEvent
Me.Requery
'when user hits newrecord and enters data into field
ElseIf Not IsNull(Me.SupplierName) Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.CancelEvent
Me.Requery
'when user edits an existing record and changes their mind
End If
buttons. The code below works great EXCEPT that when user hits button a
"second" time, vberror message pops up saying command undo isn't availble and
asking to debug. Is my code too complex or is there something I can put in to
stop the error?
If Me.NewRecord And IsNull(Me.[SupplierName]) Then
DoCmd.CancelEvent
Me.Requery 'sets focus back to top of list
'when user hits add newrecord button but has not entered any data into field
ElseIf Me.NewRecord And Not IsNull(Me.[SupplierName]) Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.CancelEvent
Me.Requery
'when user hits newrecord and enters data into field
ElseIf Not IsNull(Me.SupplierName) Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.CancelEvent
Me.Requery
'when user edits an existing record and changes their mind
End If