• passing variable between forms (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » passing variable between forms (Access 2000)

    Author
    Topic
    #405135

    Don

    Viewing 3 reply threads
    Author
    Replies
    • #829417

      I’m not 100% sure I understand teh question, but here’s a stab at an answer.

      The line of code to open a form as an option to use ‘openargs’. This could be set to PersonID. Then the form opens you use the openargs value to control the forms recordset.

      Depending on how you are controlling the recordset this might be easy, it might not be.

      open args is the last option on the DoCmd.OpenForm FormName, etc, etc, etc line of code.

      Hope this is what you were after

      Ian

    • #829418

      I’m not 100% sure I understand teh question, but here’s a stab at an answer.

      The line of code to open a form as an option to use ‘openargs’. This could be set to PersonID. Then the form opens you use the openargs value to control the forms recordset.

      Depending on how you are controlling the recordset this might be easy, it might not be.

      open args is the last option on the DoCmd.OpenForm FormName, etc, etc, etc line of code.

      Hope this is what you were after

      Ian

    • #829427

      If the main form is still open, you can use this:

      DoCmd.OpenReport stDocName, acPreview, , “[PersonID] = ” & Forms![frmMainForm]![PersonID]

      where frmMainForm should be replaced by the actual name of the main form.

      • #829582

        Thanks very much it worked! – it picked up the PersonID perfectly

        Another snag it only works if the form was the actual form and NOT a subform, I’m afraid it has to be.

        So if I just open that form (it’s called members) then it works. But if I open Household of which members is now a page on a tabbed subform, I get the message cannot find form Members.

        If I change the name to Household, then it say can’t find personID

        I do appreciate your help on a real stumbling block on this database

        Michael

        • #829586

          If your Print button is on your Household parent form and your personID is on your Members subform then you can reference the subform field using something like Me!subformName.Form!personID or from somewhere else (if the Household form is still open) using something like Forms(“Household”)!subformName.Form!personID. Note that ‘subformName’ is not necessarily the name of the subform itself (Members), but rather the name of the subform control on the parent form (Household).

          Hope this helps.

        • #829587

          If your Print button is on your Household parent form and your personID is on your Members subform then you can reference the subform field using something like Me!subformName.Form!personID or from somewhere else (if the Household form is still open) using something like Forms(“Household”)!subformName.Form!personID. Note that ‘subformName’ is not necessarily the name of the subform itself (Members), but rather the name of the subform control on the parent form (Household).

          Hope this helps.

        • #829614

          In addition to Tom’s informative reply, you can find a comprehensive overview of how to Refer to Form and Subform properties and controls on the Access Web (and you’ll find lots of other useful information there.)

          • #829772

            Guys,

            Its working!!!!

            I can open and close the Print menu form using the code Hans gave this morning and I can print reports from the details of person on the sub form using this code from Tom and Hans:-

            Private Sub CmdPersonalInvestments_Click()
            On Error GoTo Err_CmdPersonalInvestments_Click

            Dim stDocName As String

            stDocName = “RptPersonalInvestments”
            DoCmd.OpenReport stDocName, acPreview, , “[PersonID]= ” & Forms(“Household”)![Members].Form!PersonID

            Exit_CmdPersonalInvestments_Click:
            Exit Sub

            Err_CmdPersonalInvestments_Click:
            MsgBox Err.Description
            Resume Exit_CmdPersonalInvestments_Click

            End Sub

            Its been very frustating day – everthing worked I had just no room for the print options on the form

            With your help its now sorted, I’ve learnt a lot and I’m very grateful.

            Thanks a million

            Michael

            Ps and thank for pointing me to the Access web
            M

          • #829773

            Guys,

            Its working!!!!

            I can open and close the Print menu form using the code Hans gave this morning and I can print reports from the details of person on the sub form using this code from Tom and Hans:-

            Private Sub CmdPersonalInvestments_Click()
            On Error GoTo Err_CmdPersonalInvestments_Click

            Dim stDocName As String

            stDocName = “RptPersonalInvestments”
            DoCmd.OpenReport stDocName, acPreview, , “[PersonID]= ” & Forms(“Household”)![Members].Form!PersonID

            Exit_CmdPersonalInvestments_Click:
            Exit Sub

            Err_CmdPersonalInvestments_Click:
            MsgBox Err.Description
            Resume Exit_CmdPersonalInvestments_Click

            End Sub

            Its been very frustating day – everthing worked I had just no room for the print options on the form

            With your help its now sorted, I’ve learnt a lot and I’m very grateful.

            Thanks a million

            Michael

            Ps and thank for pointing me to the Access web
            M

        • #829615

          In addition to Tom’s informative reply, you can find a comprehensive overview of how to Refer to Form and Subform properties and controls on the Access Web (and you’ll find lots of other useful information there.)

      • #829583

        Thanks very much it worked! – it picked up the PersonID perfectly

        Another snag it only works if the form was the actual form and NOT a subform, I’m afraid it has to be.

        So if I just open that form (it’s called members) then it works. But if I open Household of which members is now a page on a tabbed subform, I get the message cannot find form Members.

        If I change the name to Household, then it say can’t find personID

        I do appreciate your help on a real stumbling block on this database

        Michael

    • #829428

      If the main form is still open, you can use this:

      DoCmd.OpenReport stDocName, acPreview, , “[PersonID] = ” & Forms![frmMainForm]![PersonID]

      where frmMainForm should be replaced by the actual name of the main form.

    Viewing 3 reply threads
    Reply To: Reply #829427 in passing variable between forms (Access 2000)

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

    Your information:




    Cancel