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

    Question Multiple Tables in a Single Subform - PK Issues

    Hey Everyone,

    I'm back, asking questions to problems I didn't know existed.

    I have a main form with multiple tabbed subforms (generally the info from each subform is in a separate table). Each subform shares the same PK as the main form. The issue I'm running into now is that I need display duplicate values across two subforms.

    So I have a Rates tab and a Billing tab. The Rates tab has all the dates, but there are some complex billing equations that need to be done against the rates, and I need to display the rates in the billing tab as well.When I use the Subform wizard and try to add fields from both tables, I get an error: "You have chosen fields from record sources that the wizard can't connect. You may have chosen fields from a table and from a query based on that table.If so, try choosing fields from only the table or only the query."

    I'm assuming this has to do with the parent-child key relationship and that I already have one form with half of the info in this form.
    I'm going to try to create a query with the info I need and then add it as a subform. Does anyone have any suggestions?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did you just say that each table in your subforms has the same PK as the PK of the main form? If so, that is a very unusual structure for your tables.

  3. #3
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,410
    Each subform has a recordsource "generally ... from a separate table". So you can't bind a textbox to a field in a different table. You will have to do Dlookups to the pertinent table to get those textboxes populated.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    DLookup() is an option.

    Is this a Navigation form or a Tab control on a normal form? If the latter, expressions (in VBA or textboxes) can reference controls of another subform. I do that. Name subform containers different from the objects they hold, for example ctr1, ctr2, ctr3. Following example is code behind ctr2 form that references ctr1:

    .tbxSSCret1 = 100 - Nz(Forms!DataSoilsAgg.ctr1![tbxLabOneHalf], 100)

    DataSoilsAgg is the main form these subforms sit on.
    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
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    If you need to display the data from the Rates tab on the billing tab, put a textbox on the billing tab, and make the control source for it the name of the control on the Rates tab.

    for example: if the textbox on the billing tab is to display the data from a control Rate_1 on the rates tab, put =[Rate_1] as its control source.

    That won't work if you want to save the textbox on the Billing tab into a table, because you can't bind the control to a table field. You would need a little VBA to copy the data from the controls on the Rates tab to controls on the Billing tab.

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

Similar Threads

  1. Single Primary Key for Multiple Tables?
    By lwflip in forum Database Design
    Replies: 2
    Last Post: 07-14-2015, 07:59 AM
  2. Replies: 2
    Last Post: 12-11-2014, 02:29 PM
  3. single form for multiple subform controls
    By vientito in forum Programming
    Replies: 1
    Last Post: 11-06-2014, 07:25 PM
  4. Replies: 1
    Last Post: 06-19-2012, 06:39 PM
  5. Table related to multiple tables by single ID
    By MrTumnus in forum Access
    Replies: 1
    Last Post: 11-17-2009, 02:05 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