Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    syntax for recordset of subform (A2003)

    I need to revise the following code to refer to subform recordset:

    Dim frm As Form
    Dim strForm As String

    strForm = "frmContacts"
    Set frm = Forms(strForm)

    I can't find a reference to the proper syntax. Any ideas?

    E

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: syntax for recordset of subform (A2003)

    All you're doing in that code is setting a form object variable to point to a form. What is the name of your subform, and what do you want to do with its recordset? Subforms are not open in the same sense that parent forms are, so you have to refer to a subform *through* its parent like this:

    Forms!MyForm!MySubform.Form
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: syntax for recordset of subform (A2003)

    The main form is frmContacts, the sub form is fsubAddr. The fsub has a multicolumn combo box that has information that sometimes needs to be edited. I have a command button to open a form to make editing changes. When I close that form I want to requery the combo box and set the combo box to the edited record.

    I've used this process several other places, but always on the main form and always with an unbound control using


    Dim frm As Form
    Dim strForm As String

    strForm = "frmContacts" 'set variable to name of original form
    Set frm = Forms(strForm) 'make frm refer to original form

    DoCmd.Close
    frm.Requery
    frm.RecordsetClone.FindFirst "[ContactID] = " & frm![cboFind]
    frm.Bookmark = frm.RecordsetClone.Bookmark

    E

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: syntax for recordset of subform (A2003)

    As Charlotte wrote, you must refer to the subform through the main form. Try this:

    Dim frm As Form
    Set frm = Forms!frmContacts!fsubAddr.Form
    ...

  5. #5
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: syntax for recordset of subform (A2003)

    works perfect

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •