Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open form based on subform record (Access97 SR2)

    I want to open a form based on a record selected in a subform. Can you refer to one record in a subform that displays multiple records? I know you can refer to the subform itself, but I want to refer to a particular record on the subform.

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Open form based on subform record (Access97 SR2)

    >>I want to open a form based on a record selected in a subform. Can you refer to one record in a subform that displays multiple records? I know you can refer to the subform itself, but I want to refer to a particular record on the subform.<<

    When you refer to a control on a continuous form, you are always get the value that is on the line with the focus. Perhaps you could explain exactly what you are trying to do? That is, do you want to click a button on the mainform, or is the button on the subform?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    New Lounger
    Join Date
    Mar 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open form based on subform record (Access97 SR2)

    I have a parent form with subform and button on parent form. User selects record in subform then clicks button on parent form. Button opens another form, going to (or preferably filtering to) a record (or records) related to the subform record. Does this make more sense now?

  4. #4
    New Lounger
    Join Date
    Mar 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open form based on subform record (Access97 SR2)

    Hello? Please, somebody help me.

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open form based on subform record (Access97 SR2)

    Claudie,

    In the on click event of the button use code like
    <pre>Private Sub cmdButton_Click()
    On Error GoTo Err_cmdButton_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "Yourform"
    stLinkCriteria = "[yourfield] = 'yourcondition'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_cmdButton_Click:
    Exit Sub
    Err_cmdButton_Click:
    MsgBox Err.Description
    Resume Exit_cmdButton_Click
    End Sub
    </pre>

    Francois

Posting Permissions

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