Results 1 to 14 of 14
  1. #1
    AutumnBeds is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    14

    Subform FK won't populate

    Hi All,



    Have a slight issue with a subform FK not cascading down from the main form.

    It's a many-to-many relationship. The main form should be passing down a contract number in which equipment numbers are allocated to the subform.

    Mainform hold "ContractNumber" and the subform is linked to "ContractNumberFK". The ContractNumberFK remains blank when the form is loaded.

    Any help is appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Maybe silly question, but have you properly set the subform container control Master/Child Links properties?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Can you post a screen shot of your relationships, the forms, and the subform's data properties tab?

  4. #4
    AutumnBeds is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    14
    Hopefully the below will give an idea


    Click image for larger version. 

Name:	Access1.JPG 
Views:	16 
Size:	35.0 KB 
ID:	41305Click image for larger version. 

Name:	access2.JPG 
Views:	17 
Size:	46.8 KB 
ID:	41306Click image for larger version. 

Name:	Access3.JPG 
Views:	17 
Size:	59.4 KB 
ID:	41307

  5. #5
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Looks good at first glance. It doesn't automatically populate AFTER you start entering a new row in the subform? Might just want to post the DB file for June.

  6. #6
    AutumnBeds is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    14
    Uploaded. The DB is nothing different to what I've done several times before. I'm just scratching my head.Service Trial.zipService Trial.zip

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    The zeroes in controls and #Name? errors are a concern.

    Probably should not have fields/controls with 0 as default value.

    What is RecordSource for each form - table or query?
    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.

  8. #8
    AutumnBeds is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    14
    and now all of a sudden it works again?!?!

    I restarted multiple times prior to posting as I couldn't get my head around the issue. But now it's corrected its self.

    Record sources are from a table, the #name? is due the non controlled box with a dlookup to pull through some reference information. The combo with the 0 is for selecting the equipment to be allocated to the contact.

    Click image for larger version. 

Name:	access4.JPG 
Views:	17 
Size:	54.5 KB 
ID:	41309

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Still recommend not using 0 as default value.

    Instead of DLookup, include fields in combobox RowSource (multi-column combobox). Then textbox expression references combobox columns by index. Index begins with 0 so column 2 is index 1:

    =[comboboxname].Column(1)

    Set those textboxes as Locked Yes and TabStop No.
    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.

  10. #10
    AutumnBeds is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    14
    Thanks. Will give that a try. Stilling having issues with the parent / sub form. It's stopped working again.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Will have to provide db for more help.
    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.

  12. #12
    AutumnBeds is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    14
    Quote Originally Posted by June7 View Post
    Will have to provide db for more help.
    DB attached further up.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Sorry, missed that post.

    You didn't mention getting error "The LinkMasterFields property setting has produced this error: 'Invalid outside procedure'". frm_Contracts has invalid code in its module - OpenForm command is not within a procedure. Remove this. Now I get different error "error communicating with ActiveX control". I tried removing subform container and recreating and still get error. I tried removing relationships and rebuilding form/subform. Still has issue.Don't set EquipmentNumberFK and ContractNumberFK as compound PK, set as compound index. InspectionNumber should be primary key. This table is giving me hell trying to change PK.Actually, if there are no related dependent tables, this table doesn't even need primary key.

    I rebuilt tbl_ServiceJobsJunction and deleted old one. Forms now work.

    You have field in tbl_Equipment and tbl_Contracts for Customer which is text, not number. Should be a number (long integer) to save CustomerID. Same for manufacturer. Shouldn't customer address be in tbl_Customers not tbl_Contracts? Should customer even be in tbl_Equipment?

    Could just bind frm_Contracts to table instead of query since query doesn't filter or sort or join to another table.
    Why is there no tbl_Inspections?

    I still don't think should have 0 set as default value for any fields in this db schema.
    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.

  14. #14
    AutumnBeds is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    14
    June, many thanks.

    I rebuilt the table and it worked fine.

    The address was put into the contracts as a temporary measure so that I could give the service engineer details of his job. Planning to move this into a separate table.

    Also tidied up the other bits and pieces as recommended.

    Thanks.

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

Similar Threads

  1. Subform fails to populate
    By cebrower in forum Forms
    Replies: 2
    Last Post: 01-03-2020, 09:02 AM
  2. Replies: 13
    Last Post: 09-10-2015, 03:37 PM
  3. Populate a subform with data
    By intransit2 in forum Forms
    Replies: 1
    Last Post: 03-06-2012, 07:33 PM
  4. Populate table/subform from VBA
    By degras in forum Forms
    Replies: 3
    Last Post: 03-03-2011, 10:59 AM
  5. how to populate a subform from table
    By Dengkee in forum Programming
    Replies: 1
    Last Post: 10-18-2010, 08:09 AM

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