Results 1 to 4 of 4
  1. #1
    mnjohn is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2017
    Posts
    16

    Arrow text box

    hi


    i have a table (tblnames) which has 2 fields that are ( id and name ).

    then i create a form (frmnames) that has 2 text boxs..

    textbox1 and textbox2...


    now what i want to do is that when i enter id number in textbox1 the 2nd textbox should shows the name of that id which is on my table (tblnames).

    and if i put name in textbox2 it shows the id of that relevant name...........

    thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    use the afterupdate events. Notice the ID is numeric so there are no delimiters, and
    to lookup NAME field, a string, it will require delimiters in the dlookup...

    Code:
    sub txtBox1_afterupdate()
       txtBox2 = Dlookup("[Name]","table","[id]=" & txtBox1)
    end sub
    
    sub txtBox2_afterupdate()
       txtBox1 = Dlookup("[ID]","table","[name]='" & txtBox2 & "'")
    end sub

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    That's fine as long as there is only one John Smith and user correctly spells name. Why not use a combobox?

    Is ID an autonumber primary key? Why would user enter ID? Why would user even be aware of an autonumber primary key?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    And "Name" is a reserved word in Access.
    Reserved words should not be used as object names.

    Unless this is for your personal use, how is a used supposed to know how to enter the name?
    Options could be:
    Jon Smith
    J. R. Smith
    JR Smith
    Smith, Jon
    Smith Jon (no comma)
    Smith JR

    Better to have FirstName and LastName or GivenName and Surname


    Also, having the FirstName and LastName in one field violates "First normal form (1NF)"..... if you want to talk about normalization..

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 07-05-2017, 02:36 PM
  2. Replies: 1
    Last Post: 05-18-2016, 09:46 AM
  3. Replies: 2
    Last Post: 07-09-2014, 12:43 PM
  4. Replies: 3
    Last Post: 02-07-2013, 09:53 PM
  5. Replies: 1
    Last Post: 05-24-2012, 04:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums