Results 1 to 3 of 3
  1. #1
    khayward is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2017
    Location
    Oregon
    Posts
    89

    Command button in subform to open another form at specific record

    Hi all,


    I've dug into this a fair bit already and not found anything that worked, including an almost identical situation. I have a form with subform (Screenshot attached) inside a tabbed control. The subform draws from a junction table relating components to assemblies. I wanted a button for each record in the subform that will, when clicked, open the form which contains information about the components at the record for the component in question. When I use the control wizard and it asks which fields to match I get the field list for the form I want to open, but the field list for the current subform is blank. I've tried, using the expression editor, to add a 'where' clause to match the field from the subform to the destination form but to no avail.
    The argument for that piece looks like this: frmMaterials, Form, , [Forms]![frmMaterials]![PartID]=[Forms]![frmAssemblies]![subfrmBOM].[Form]![PartID], , Normal

    I'm not sure if it matters but the destination form has, in the header, a combobox set up as a search box.

    Any thoughts on how to make it work?

    Click image for larger version. 

Name:	assemblies form screenshot.png 
Views:	14 
Size:	53.6 KB 
ID:	38021

  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, use Me:
    docmd.openform "fMyForm",,,"[id]=" & me.txtID

    if the button is on the master form, but the ID is on the subform, use the full path to the subform:
    docmd.openform "fMyForm",,,"[id]=" & me.subform.form.txtID

    (if the ID is a string , put single quotes around the object path)
    "[id]='" & me.subform.form.txtID & "'"

  3. #3
    khayward is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2017
    Location
    Oregon
    Posts
    89
    Quote Originally Posted by ranman256 View Post
    if the button is on the subform, use Me:
    docmd.openform "fMyForm",,,"[id]=" & me.txtID

    if the button is on the master form, but the ID is on the subform, use the full path to the subform:
    docmd.openform "fMyForm",,,"[id]=" & me.subform.form.txtID

    (if the ID is a string , put single quotes around the object path)
    "[id]='" & me.subform.form.txtID & "'"
    Thanks for the quick reply. My button was in the subform. I used code builder and put the following in:
    Private Sub cmdOpenMtlsForm_Click()
    DoCmd.OpenForm "frmMaterials", , , "[PartID]=" & Me.PartID
    End Sub

    This seems to work like a charm, thank you!

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

Similar Threads

  1. Replies: 5
    Last Post: 01-07-2019, 11:45 AM
  2. Replies: 4
    Last Post: 08-10-2018, 12:00 AM
  3. Replies: 3
    Last Post: 07-22-2018, 02:05 PM
  4. Replies: 2
    Last Post: 10-08-2012, 12:39 PM
  5. Replies: 2
    Last Post: 05-11-2012, 11:52 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