• SubForm Search (v2000)

    Author
    Topic
    #389341

    I have a single-form with a company name and a main contact for each company. I have a linked subform with a list of additional contact names. If I search for a main contact name, I go to the record easily. If I search for an additional contact name it can’t find the name because the subform references the current record. I understand why it can’t find the additional contact…I am just wondering the best way around this. How can I search the subform for additional contact names and go to the correct company?
    Thanks!!

    Viewing 0 reply threads
    Author
    Replies
    • #687122

      Maybe you could put a combobox on the main form that queries the contacts and once you have the contact then set a bookmark on the main form based upon the Company name.

      • #687159

        I tried this:
        Private Sub txtContName_AfterUpdate()
        ‘Find the record that matches the control.
        Forms![frmSwitchboard]![Customer Data].RecordsetClone.Findfirst “[txtCustID] = ” & Me.txtCoID
        Forms![frmSwitchboard]![Customer Data].Bookmark = Forms![frmSwitchboard]![Customer Data].RecordsetClone.Bookmark
        End Sub
        where ‘Customer Data’ is the name of a tab and ‘txtContName’ is a control on the subform. However, it doesn’t move to the desired record.

        • #687161

          [indent]


          where ‘Customer Data’ is the name of a tab


          [/indent] You don’t reference tab controls at all in expressions like this. The syntax to use in addressing a subform would be:

          Forms!MyForm!SubformControlName.Form!ControlOnSubform

          If the code is being run inside the parent form, you can use the Me reference like this:

          Me!SubformControlName.Form.RecordsetClone
          Me!SubformControlName!ControlOnSubform

          Understand that the subform control name can be different from the name of the actual subform bound to it, and you have to tell Access whether you’re talking about the subform control or the subform itself (SubformControlName.Form). When you need a recordsetclone, you must specify the .Form in order to let Access know what you mean, since the subform *control* doesn’t have a recordset, let alone a recordsetclone.

    Viewing 0 reply threads
    Reply To: SubForm Search (v2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: