Results 1 to 5 of 5
  1. #1
    wtucker is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jun 2017
    Posts
    50

    Question SQL Select value from other table

    Hello everyone,



    I have a form with multiple subforms and multiple tables. I have a field in Table1 that needs to pull a value from Table2 depending on the value of another field in Table1.

    Table2 has a list of each U.S. state and a different Carrier value for each. I'm assuming I'd need to use a SQL command, like

    Code:
    SELECT Carrier FROM
    State Carriers (table name)
    WHERE State = [Client].[State];
    Can someone help me piece this together?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Thread already marked solved - is it?

    No, SQL would not be like that.

    Use real table names in your post narrative.

    Suggest you use a combobox with RowSource from Table2 and then textboxes can reference columns of combobox. With combobox, save record ID from Table2.

    Then build query that joins the tables on primary and foreign key fields.
    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.

  3. #3
    wtucker is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jun 2017
    Posts
    50
    I thought I found the solution but it turned out to be a partial one.

    Fields in the form:
    Issue State
    Carrier

    Carriers Table:
    State
    Carrier

    I have the combo box with the row source from the Carriers table. How can I reference the other column of the combo box in the text box?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Reference the column by its Index. Index begins with 0. Column 2 has an Index of 1.

    =comboboxname.Column(1)

    Make sure the combobox ColumnCount, ColumnWidths, BoundColumn properties are correctly set.
    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.

  5. #5
    wtucker is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jun 2017
    Posts
    50
    This worked great! Thank you!

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

Similar Threads

  1. Replies: 4
    Last Post: 09-07-2016, 05:02 AM
  2. Update table with inner select
    By Andy camp in forum Queries
    Replies: 1
    Last Post: 01-20-2013, 12:48 AM
  3. Replies: 2
    Last Post: 09-18-2012, 06:20 AM
  4. Replies: 1
    Last Post: 06-08-2011, 04:43 AM
  5. Replies: 2
    Last Post: 03-14-2010, 07:27 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