How to link text boxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Routergal
    New Member
    • Dec 2009
    • 3

    How to link text boxes

    I am trying to link a text box Employee ID (EMPLID) so that when the user enters the EMPLID the NAME appears in the second text box called NAME. Here is what I have so far...I keep getting runtime errors though...

    Code:
    Private Sub EMPLID_AfterUpdate()
       Me!NAME = DLookup("NAME", "PS_PERONSAL_DATA", "EMPLID" = "" & Me!EMPLID.Value & "NAME")
    End Sub
    Last edited by Frinavale; Jun 1 '10, 06:45 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    What are you trying to do with

    & "NAME"?

    This is tacking the word "Name" onto control named EMPLID in your form, which makes no sense to me. If EMPLID is Numeric then
    Code:
    Me!NAME = DLookup("NAME", "PS_PERONSAL_DATA", "[EMPLID] = " & Me!EMPLID.Value)
    should work. If EMPLID is Text then it would be
    Code:
    Me!NAME = DLookup("NAME", "PS_PERONSAL_DATA", "[EMPLID] = '" & Me!EMPLID.Value & "'")
    You also need to change your field name to something other than Name, which is a Reserved Word in Access. It's very apt to confuse the Access Gnomes, sooner or later.

    Also note that when error messages are being incurred, it would really help to post those errors when starting a thread.

    Welcome to Bytes!

    Linq ;0)>

    Comment

    • Routergal
      New Member
      • Dec 2009
      • 3

      #3
      Originally posted by Routergal
      I am trying to link a text box Employee ID (EMPLID) so that when the user enters the EMPLID the NAME appears in the second text box called NAME. Here is what I have so far...I keep getting runtime errors though...

      Code:
      Private Sub EMPLID_AfterUpdate()
         Me!NAME = DLookup("NAME", "PS_PERONSAL_DATA", "EMPLID" = "" & Me!EMPLID.Value & "NAME")
      End Sub
      Thank you so much for your help. EMPLID was a number and I fixed my code. It works great.

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        Glad we could help!

        Linq ;0)>

        Comment

        Working...