confusedoes any one have a solution for the problem with a setfocus following an undo and cancel event raising the following error?
Run-time error 2108: You must save the field before you execute the
SetFocus method.
I am trying to a "simple" data validation. Based on a choice in an option group (yes/no), certain data is required.
For example, if the client selects "yes", then 3 bond controls must be populated. If they are not I want to 1) "deselect option 3" 2) send a message 3) move the focus to the first missing control
Here is my code for the first required control:
Private Sub GroupClearance_BeforeUpdate(Cancel As Integer)
If Me.GroupClearance And Nz(Me.WorkRequirements, "") = "" Then
MsgBox "For Group Clearance, you must enter Work Requirements!"
Cancel = True
Me.GroupClearance.Undo
Me.WorkRequirements.SetFocus
Exit Sub
End If
No matter what I try, I get error 2108. I have tried every we I know how to force a save (Docmd.Runcommand acCmdSaveRecord, setting Me.Dirty = true).
The problem seems to arise from the record being left "dirty" from the undo and cancel event. How do I "undirty" it so I can proceed?
Thanks for your help. I have spent many hours already resaerching this and trying everything I know to no avail.
Run-time error 2108: You must save the field before you execute the
SetFocus method.
I am trying to a "simple" data validation. Based on a choice in an option group (yes/no), certain data is required.
For example, if the client selects "yes", then 3 bond controls must be populated. If they are not I want to 1) "deselect option 3" 2) send a message 3) move the focus to the first missing control
Here is my code for the first required control:
Private Sub GroupClearance_BeforeUpdate(Cancel As Integer)
If Me.GroupClearance And Nz(Me.WorkRequirements, "") = "" Then
MsgBox "For Group Clearance, you must enter Work Requirements!"
Cancel = True
Me.GroupClearance.Undo
Me.WorkRequirements.SetFocus
Exit Sub
End If
No matter what I try, I get error 2108. I have tried every we I know how to force a save (Docmd.Runcommand acCmdSaveRecord, setting Me.Dirty = true).
The problem seems to arise from the record being left "dirty" from the undo and cancel event. How do I "undirty" it so I can proceed?
Thanks for your help. I have spent many hours already resaerching this and trying everything I know to no avail.