Results 1 to 5 of 5
  1. #1
    chalupabatman is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    114

    Selected Record From Sub Form

    I have a form with a sub-form, and the sub-form is based off a select query with a userID. I want to be able to have a way where if the user selects a row from the sub-form, they can then press a command button and a second form is opened with ONLY information that is related to the selected record is displayd.



    Is this possible in Access 2013 and if so, how would you achieve such?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    IF the button is on the subform (in header) then open the new form, using the key field in the subform:

    docmd.openform "frmMyForm",,,"[id]=" & me.id

  3. #3
    chalupabatman is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    114
    I was going to place the button on the main form, and only have the sub form be the "grid" from the query. Is it still possible?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    if you put it on the main , use the builder to get the path correct. It will be like:

    docmd.openform "myForm",,,"[id]=" & me.subform.form.txtID

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I don't think it's intuitive to have to click on a record in the subform and then go click on a button on the main form. I'd either have a button in the subform, or put the code in the double-click event of a subform textbox. ranman gave you the correct code, but if the field has a different data type you'll need delimiters:

    BaldyWeb wherecondition
    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: 3
    Last Post: 09-19-2016, 06:46 AM
  2. Replies: 3
    Last Post: 02-06-2015, 01:18 PM
  3. Print only selected record of a sub form
    By falahsalih in forum Access
    Replies: 10
    Last Post: 05-11-2014, 09:28 AM
  4. Replies: 3
    Last Post: 09-20-2012, 11:09 AM
  5. Loading the form with selected record
    By emilylu3 in forum Access
    Replies: 1
    Last Post: 12-09-2005, 07:49 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