Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2002
    Posts
    68

    Unanswered: Microsoft Access VB Run Time Error '2185'

    Question: I have a form with with a text box and when the user enters his information into text box after it saves I want it to automatically add the text ADA-xxxx. I have tried using MS accesses Build Event and choose "Expression Builder" But I am getting an error. Can Someone please help me???


    The Error I am getting is:

    Microsoft Access
    Run-time error '2185':

    "You can't reference a property or method for a control unless the control has the focus. Try one of the following: 1) Move the focus to the control before you reference the property. In Visual Basic code, use the SetFocus method. In a macro, use the GoToControl action.
    2) Reference or set the property from a macro or event procedure that runs when the GotFocus event for the Control occurs."



    My Code is listed below:


    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Left(LABEL_TAG.Text, 4) <> "ADA-" Then
    LABEL_TAG.Text = "ADA-" & LABEL_TAG.Text
    End If
    End Sub

  2. #2
    Join Date
    Aug 2002
    Location
    Cambridge, England
    Posts
    47

    Cool

    Try putting in the SetFocus method as advised by Access, i.e.

    Private Sub Form_BeforeUpdate(Cancel As Integer)

    Me.LABEL_TAG.SetFocus

    If Left(LABEL_TAG.Text, 4) <> "ADA-" Then
    LABEL_TAG.Text = "ADA-" & LABEL_TAG.Text
    End If
    End Sub

    This should sort the problem :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •