Results 1 to 4 of 4
  1. #1
    ngonzalz is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    5

    Auto Populate Subform Records - and link with field on Main Form


    Hello!

    I am using a command button event to auto populate a set of tasks for each main record. Currently I am able to append all task descriptions into my tasks table - however I need to link them to the ShowID of my main form.

    Following details:

    tblTaskDescriptions
    ..ID
    ..TaskDesc

    tblTasks
    ..ID
    ..Show ID
    ..Task

    frmShows
    ..subfrmTasks
    ..command button

    Current Code on button
    Code:
    DoCmd.RunSQL "INSERT INTO tblTasks (Task) " & _
    "SELECT TaskDesc " & _
    "FROM tblTaskDescriptions " & _
    "WHERE [ShowID]=[Forms]![Shows]![ShowID];"
    I'm not sure what to add in for WHERE or if I can use this parameter at all.

    Thanks for your help!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Add the show ID field to the INSERT INTO clause and the form reference to the SELECT clause.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ngonzalz is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    5
    Quote Originally Posted by pbaldy View Post
    Add the show ID field to the INSERT INTO clause and the form reference to the SELECT clause.
    That worked great, thank you much! :^)


    Code:
    DoCmd.RunSQL "INSERT INTO Tasks (Task, ShowID) " & _
    "SELECT TaskDesc, [Forms]![Shows]![Show ID] " & _
    "FROM tblTaskDescriptions " & _
    "WHERE [Show ID]=[Forms]![Shows]![Show ID];"

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 09-16-2014, 12:32 PM
  2. Replies: 3
    Last Post: 01-05-2012, 07:15 PM
  3. Replies: 3
    Last Post: 10-03-2011, 02:33 PM
  4. Replies: 12
    Last Post: 08-30-2011, 03:36 PM
  5. Replies: 0
    Last Post: 06-23-2009, 03:01 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