Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2013
    Posts
    3

    Unanswered: Fill up text box from value selected in combobox

    I am working with MS Access 2007. I have a table that contains student names corresponding to student IDs. I have student IDs in another relationship table and a form that has a combobox that contains all the student IDs from the relationship table. What I want to be able to do is, upon selection of a student ID from the combobox, another text box in the same form will be automatically filled up with the student name by looking up the student table. I have been trying to achieve this since last night so any help will be highly appreciated. Thanks

  2. #2
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    994
    Provided Answers: 2
    The easiest way is to include the student name in the RowSource for the combo box, and then use the AfterUpdate event to drop the name relating to the selected ID into the text box.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  3. #3
    Join Date
    Apr 2013
    Posts
    3
    Thank you very much for your reply. But I was wondering how to do this using recordset and writing select code since I have to do this for a couple of other text boxes on the form. Thank you again

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    create a query which returns the student ID (the primary key of students) and the student name as say LastName & "," & Forename
    set the sort order to be the newly created name
    eg
    Code:
    SELECT studentID, LastName & "," & Forename & ";" & Title as FullName from Students
    ORDER by StudentsName
    change the table name and column names to be whatever they are in your application

    OR

    plonk the students table inot the query designer
    pull the primary key into one column, then in the next column
    FullName: LastName & "," & Forename & ";" & Title
    set the sort to be ASC under the FullnameColumn

    save the query

    then use that query as the source for your combo boxes

    if you need the students full name in say reports then JOIN the query to the other tables
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Apr 2013
    Posts
    3
    Thank you very much

Posting Permissions

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