Biz,
Your assumption on error message is correct. With your instructions, I have
worked out below statement. However, I believe the user will have further
request once the missing item has filled, the focus should move back to
FieldD. How can I do it without normal tab order?
Private Sub txtFieldD_Change()
If IsNull([FieldA]) Then
If MsgBox("The FieldA is empty. Please fill that first!",
vbRetryCancel, "Missing data") = vbRetry Then
Me.txtFieldD = ""
Me.txtFieldA.SetFocus
End If
End If
If Not IsNull([FieldB]) And IsNull([FieldC]) Then
If MsgBox("FieldC is empty. Please fill that first!", vbRetryCancel,
"Missing data") = vbRetry Then
Me.txtFieldD = ""
Me.txtFieldC.SetFocus
End If
End If
End Sub
Thanks,
Scott
Biz Enhancer said:
Quite possibly you are getting a 2108 error which is:
"You must save the field before you execute the GoToControl action, the
GoToControl method, or the SetFocus method."
Put this in the "on Change" event instead:
Private Sub FieldA_Change()
If IsNull([FieldA]) Then
If MsgBox("The FieldA is empty. Please fill that first!", vbRetryCancel,
"Missing data") = vbRetry Then
Me.FieldB = ""
Me.FieldA.SetFocus
Else
'Do something else
End If
End If
End Sub
That will get past the error and ensure that the user can't go any further
in the form until FieldA has that data.
Hope it helps,
Regards,
Nick.
Scott said:
I have below event in a form and stuck how to move to other field. It
comes
up asking me to end the operation at FieldB before moving to FieldA.
Private Sub txt1stFieldB_BeforeUpdate(Cancel As Integer)
If IsNull([FieldA]) Then
MsgBox "The FieldA is empty. Please fill that first!"
Cancel = True
Me.txtFieldA.SetFocus
End If
End Sub
Any idea to fix it?
Thanks,
Scott