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

Discussion in 'Access Forms Coding' started by rmcompute, Sep 2, 2006.

  1. rmcompute

    rmcompute 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
     
    rmcompute, Sep 2, 2006
    #1
    1. Advertisements

  2. rmcompute

    J. Goddard Guest

    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
     
    J. Goddard, Sep 2, 2006
    #2
    1. Advertisements

  3. rmcompute

    rmcompute Guest

    It worked. Thank you.

     
    rmcompute, Sep 3, 2006
    #3
  4. rmcompute

    don

    Joined:
    Mar 17, 2014
    Messages:
    1
    Likes Received:
    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!



     
    don, Mar 17, 2014
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.