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

    Question Accessing multiple forms with the same Primary Key.

    I'm running into an issue with the database I'm trying to create. I have about 200 fields (and thousands of records), so I split them into about 8 different tables based on category, which all share the same PK. I only want to have to write the PK once, and store it in each table.
    I've been trying to create a form with information from multiple tables (I'll need to make about 6 of these), but I've been getting the error "The Microsoft Access database engine cannot find a record in the table 'Contracts' with key matching field(s) 'ClientID'".

    I originally wanted to have a main form with buttons to open other forms to the same record.
    It would work like this:
    Open main form.
    For new customer, fill in information (including PK based on unique client ID), click buttons to open additional forms to fill out for new record (but same PK).
    For existing customer, click buttons to open additional forms to correct record.



    I know there has to be a better way to do this, but I'm lacking in technical experience. Hopefully someone can help me solve this in terms I can understand.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    docmd.openform "form1",,,"[key]=" & me.txtID
    docmd.openform "form2",,,"[key]=" & me.txtID

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Try using a main form - subform setup, with each of the subforms on its own tab, being sure to set the parent - child links to the PK field in each subform.

  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
    Quote Originally Posted by wtucker View Post
    I know there has to be a better way to do this, but I'm lacking in technical experience. Hopefully someone can help me solve this in terms I can understand.
    Maybe you could post a picture of the relationships or your dB with just a few records in each table.
    It sounds like you have non-normalized table structures.

    Quote Originally Posted by wtucker View Post
    <>snip I have about 200 fields (and thousands of records), so I split them into about 8 different tables based on category, which all share the same PK. I only want to have to write the PK once, and store it in each table.
    So you have a main table with 8 related tables? Each of the 8 tables has a foreign key field that links to the main table PK field?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    This is 1-to-1 relationship and a form/subform structure is still relevant. As John_G suggested, subforms can be placed on pages of Tab control or use a Navigation Form. The forms can all be in Single View.

    I agree that 200 fields is a lot and the db may not be normalized. However, 1-to-1 might be justified. I have a database that uses 1-to-1 relationship extensively. It is to track laboratory test data of construction materials. Each sample can have multiple tests designated but only one of each test. Each test has its own table to hold the raw data used to calculate reported results. We have over 200 tests to select from (usually less than a dozen are required). The primary purpose of database is to facilitate generation of test results reports. Very little actual aggregate data analysis takes place. This structure makes generating the results reports easier. The output varies in structure according to material being tested so there is no 1-size-fits-all report. I do have to graph some data and all of the graphs require use of UNION queries to rearrange data. Of course, on the rare occasion a new test is defined, modifying the db to accommodate is not a simple effort.
    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.

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

Similar Threads

  1. Replies: 13
    Last Post: 12-28-2016, 11:39 AM
  2. Accessing Database by multiple user at a time
    By prasadmng555 in forum Programming
    Replies: 3
    Last Post: 11-23-2016, 08:29 AM
  3. Replies: 10
    Last Post: 03-29-2016, 12:20 PM
  4. Replies: 3
    Last Post: 10-21-2010, 10:54 AM
  5. Multiple users accessing same database
    By 4ACE in forum Access
    Replies: 0
    Last Post: 02-28-2008, 03:10 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