Results 1 to 6 of 6
  1. #1
    colbywolford is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2014
    Location
    Souderton, PA, USA
    Posts
    11

    Question Autopopulate fields in child form from parent record when opening with command button

    Hello...I apologize if this question has been covered before; if so, please post a link to the answered thread and I'll look there. As of right now, I have waded through many posts and haven't found my answer--probably because I'm not searching for the correct terms. I uploaded screen shots of the forms I'm asking about.


    Click image for larger version. 

Name:	frmAuthors.PNG 
Views:	10 
Size:	16.9 KB 
ID:	16421Click image for larger version. 

Name:	frmBooks.PNG 
Views:	10 
Size:	15.0 KB 
ID:	16422

    Here's my setup: I am an editor and am keeping track of all the authors I work with, along with their books that I edit and any events (correspondence, rejections, contract offers, etc.) So, for my question here, I am using my frmAuthors. This form has all the contact data for the author and sfrmBooks that simply lists all the titles the author has submitted for review. I have another form (frmBooks) that lists all the pertinent information regarding specific titles including the ID of the author who wrote it. Now, frmAuthors has a one-to-many relationship with frmBooks because one author can have many titles.

    Now, here's the question. I have a command button on frmAuthors named addTitle which opens frmBooks to [acNewRecord]. What I want to do is use that command button, addTitle, to open to the new record and auto-populate the authorID field from the specific frmAuthors parent record. How do I do this?

    Thanks,
    Colby

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Forms!frmAuthors.authorID = Forms!frmAuthors.authorID
    FYI: You can always use the wizard and have it build it for you so you can learn.

    HTH

  3. #3
    colbywolford is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2014
    Location
    Souderton, PA, USA
    Posts
    11
    Where do I enter that? And doesn't one side of the expression have to be Forms!frmBooks.authorID?

    I used the wizard to create the command button with the embedded macro to open frmBooks which looks like:
    Code:
    OpenForm
       Form Name frmBooks
       View Form
       Filter Name
       Where Condition = [acNewRecord]
       Data Mode Add
       Window Mode Normal

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Yes, I was in a hurry. Forms!frmBooks.authorID = Forms!frmAuthors.authorID
    However, we would need to know the field names to get the correct syntax from both forms.

  5. #5
    colbywolford is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2014
    Location
    Souderton, PA, USA
    Posts
    11
    Forms!frmBooks.authorID = Forms!frmAuthors.authorID

    These field names are correct. However, I still don't know where to input this line.

  6. #6
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    You could open your form (frmBooks) to a new record by default or by code. Create a command button on your form as you did with the AddTitle or else a new one and then add that code. As I said, I don't use macros.

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

Similar Threads

  1. Replies: 4
    Last Post: 09-13-2013, 05:26 PM
  2. Replies: 3
    Last Post: 07-03-2013, 01:20 PM
  3. Replies: 10
    Last Post: 02-12-2013, 05:04 PM
  4. How to make Parent field store sum of child fields
    By Alexandros in forum Database Design
    Replies: 10
    Last Post: 03-19-2012, 10:41 AM
  5. Delete child records with parent record
    By jpkeller55 in forum Access
    Replies: 8
    Last Post: 09-07-2010, 08:52 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