Error number: 2108 You must save the field before you .....

G

Guest

I received the following message:

Error number: 2108 You must save the field before you execute the
GotoControl action, the GoToConrol method or the SetFocus method.

The form contains a combo box, HRNum, with the Limit to list property set to
No.
There is a sub HRNum_BeforeUpdate which contains the following code to test
for a missing HR Number. I know that the Set Focus is causing the error,
however, when I used a text field instead of a combo box there was no error
and how could I "save the field" as it states in the error.

Private Sub HRNum_BeforeUpdate(Cancel As Integer)

If IsNull(Me.HRnum) Then
Me.HRnum.Undo
Me.HRnum.SetFocus
Cancel = MsgBox("You must enter an HR number.", vbCritical, "Data
Validation Failure")
End If
 
J

J. Goddard

Try taking the SetFocus method out - you are already on the HRNum
control, and setting Cancel to non-zero prevents you from leaving the
control.

Hope this helps.

John
 
G

Guest

It worked. Thank you.

J. Goddard said:
Try taking the SetFocus method out - you are already on the HRNum
control, and setting Cancel to non-zero prevents you from leaving the
control.

Hope this helps.

John
 

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