Results 1 to 10 of 10
  1. #1
    mikichi is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2013
    Posts
    45

    question|connect between entry and text box fields


    hi again,
    i have a form that has a 3 column: ID, first name and last name.
    and i also have a table that have a same column (ID, first name and last name).
    i want that when i write the ID, access fill the first name and last name fields in a right data - the first and last names of ID entry
    Example:
    if my table like that:
    ID last name first name
    13456 Elen Miki

    when i write in form in ID text box: 123456, in last name field appear Elen and in first name appear Miki.
    thank youuuuuu,
    miki

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Have you tried using a combobox on your form? You can use the wizard to help build one. Just make sure you have a textbox control on your form that is bound to your "ID" field before you begin.

  3. #3
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Use the afterupdate event of the ID box to set the other two fields.

    You could use DFirst or DLookup to load them. http://www.techonthenet.com/access/f...in/dlookup.php

  4. #4
    mikichi is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2013
    Posts
    45
    Quote Originally Posted by ItsMe View Post
    Have you tried using a combobox on your form? You can use the wizard to help build one. Just make sure you have a textbox control on your form that is bound to your "ID" field before you begin.
    thank you, but i dont have a combo box. i have a three textBoxes, and i want that when i fill one. the others update auto.
    Use the afterupdate event of the ID box to set the other two fields.

    You could use DFirst or DLookup to load them. http://www.techonthenet.com/access/f...in/dlookup.php
    thank you, i try to use a dLookUp in afterUpdate in ID:
    how access know that i want update first/last name text box? dLookUp function not have this argument.

    i repeat, i have a three textBoxes, and i want that when i fill one. the others update auto from table.
    sorry on my horrible english.
    thank you,
    miki

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Is your form bound to a table or query?

    Is your first textbox bound to a field?

    Are the other two textboxes bound to fields?

  6. #6
    mikichi is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2013
    Posts
    45
    Quote Originally Posted by ItsMe View Post
    Is your form bound to a table or query?

    Is your first textbox bound to a field?

    Are the other two textboxes bound to fields?
    \
    my form is bound to other table.
    last & first name not bound to any field.

    ID text box bound to table that i want take form him the first&last names.
    thank you!!!

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I don't believe you answered all of my questions. So...

    The form is bound to a table

    You have a textbox "FirstLastName" that is unbound

    You have a textbox bound to the ID field on a table.

    If you are going to type something into a textbox, you will need another unbound textbox. This could start a "Search" for the ID. It sounds like this ID field is already available on the form.

    Instead of a creating another unbound textbox, ehy not use the built in search functions of Access? You can set focus on your ID field and type your "Search" there.

    Then your unbound textbox "FirstLastName" can display the two names in one text box.

    On your form, add "FirstName" and "LastName" textboxes. They should be bound to their reapective fields.

    Then, in your unbound text box "FirstLastName" type the following..


    Code:
    =[FirstName] & " " &[LastName]

  8. #8
    mikichi is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2013
    Posts
    45
    sorry, i think that you dont understood my question because my english.
    i have a textBox named "ID".
    i want that when i write ID in ID textBox i get the name from a table in Name text Box in my form. like the paint i added to this reply.
    my form that ID and Name inside him bound to other table.
    thank you,
    miki
    Attached Thumbnails Attached Thumbnails paint.jpg  

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    You should not be updating a field that is a key to a record. If ID is bound to a table you should not be able to edit that field. Granted, you can type in a driver license number or another type of Id that can, at a later time, be used as a key. However you can not create a key, on the fly.

    I don't know of a way to type into a bound textbox and have that textbox search for a record. If, somehow, you force this to work, then what is the point of the textbox being bound?

  10. #10
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Mikichi -
    1) Make sure the form is bound to the table, and bind the other two fields to the name fields in the table and see if it works without any further effort. It probably will.

    If it does not, the reason will be because Access will be complaining that you are trying to change the key field.

    If that happens, then try this -

    2) Add a new, unbound, combo box to the form, and put this in the afterupdate event of the combo box. In the below code I Called it CboID.
    Code:
    Private Sub cboID_AfterUpdate()
        ' Find the record that matches the control.
        Dim rs As Object
        Set rs = Me.Recordset.Clone
        rs.FindFirst "[ID] = " & Str(Nz(Me![cboID], 0))
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub
    Assuming you bound the form to the table, and all three text boxes to fields in the table, that code should cause all three text boxes to update each time the combo box is changed.

    If this works, then you should set the ID text box so that the ID data cannot be changed.

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

Similar Threads

  1. Replies: 4
    Last Post: 08-25-2012, 07:19 PM

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