• Open form based on subform record (Access97 SR2)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Open form based on subform record (Access97 SR2)

    Author
    Topic
    #359955

    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.

    Viewing 0 reply threads
    Author
    Replies
    • #540828

      >>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?

      • #540833

        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?

        • #540953

          Hello? Please, somebody help me.

        • #540957

          Claudie,

          In the on click event of the button use code like

          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
          
    Viewing 0 reply threads
    Reply To: Open form based on subform record (Access97 SR2)

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

    Your information: