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

R

rmcompute

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
 
R

rmcompute

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
 

don

Joined
Mar 17, 2014
Messages
1
Reaction score
0
Very Helpful, thank you J Goddard!

I am in an advanced database class at SCF in Bradenton, FL and this tip was very helpful on an assignment that kept the phone number area code set to specific digits. I removed the SetFocus method and it worked like a charm :D Thank you 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


rmcompute wrote:
> 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
>
>
 

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