Results 1 to 3 of 3
  1. #1
    dwheatley is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    22

    Creating a subform - you cannot add or change a record because a related field...

    Hi all,



    I have a form which I use to save new data to a table.

    Within that form I want a subform which allows my colleagues to quickly view the information they have entered previously, and edit that information if necessary. The tables are all in a back-end database and I'd like to utilise the subform so that it is easy for them to check back that they have correctly entered their data.

    I haven't used subforms before. On my form I created one from the controls in the design tab. At this point I am guessing: for where I want the data for the subform to come from, I chose 'Use existing tables and queries' and selected the table which the main form saves data to.

    'Would you like to define which fields link your main form to this subform yourself, or choose from the list below?' - any guidance here? I have tried a few different options, including 'none', and keep getting two errors from access related to one of my fields (pictured here). Click image for larger version. 

Name:	subform2.PNG 
Views:	22 
Size:	43.1 KB 
ID:	31937Click image for larger version. 

Name:	subform.PNG 
Views:	22 
Size:	51.2 KB 
ID:	31938

    Sorry for the long-winded explanation. I'd really appreciate any advice as to how best to implement what I'm trying to do.

    Thanks!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    the subtable MUST have the same key field in tService as in the master table,tCompany:

    ex: tCompany table:
    CoID (autnum)
    CoName (text)

    tService table:
    CoID (long)
    ServiceID (autonum)
    ServiceDate
    etc

    here CoID exists in both AND in the relationships, you must join CoID and set it ENFORCE REFERENTIAL ENTEGRITY. (and the Cascades)
    Then you can have 1 Company to Many services.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by dwheatley View Post

    ...I chose 'Use existing tables and queries' and selected the table which the main form saves data to.
    This sounds like you're using the same Record Source for both Main Form and the Subform...is that the case?

    Linq ;0)>

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

Similar Threads

  1. Replies: 3
    Last Post: 06-02-2017, 02:33 PM
  2. Replies: 6
    Last Post: 07-28-2016, 06:07 PM
  3. Replies: 15
    Last Post: 03-05-2015, 03:30 PM
  4. Replies: 1
    Last Post: 12-05-2014, 07:47 PM
  5. Replies: 40
    Last Post: 08-20-2013, 11:38 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