none
Open multiple forms with a where condition to open each one at a specific record RRS feed

  • Question

  • I have changed opening a new form when a button is pressed from:

    DoCmd.OpenForm "Workform", _
        WhereCondition:="WorkteamID=" & Me.[txtWorkteamID]

    to calling this function written by Allen Browne, that enables multiple forms to open:

    Function OpenAClient()

        'Purpose:   Open an independent instance of form frmClient.

        Dim frm As Form

         'Open a new instance, show it, and set a caption.

        Set frm = New Form_frmClient

        frm.Visible = True

        frm.Caption = frm.Hwnd & ", opened " & Now()

         'Append it to our collection.

        clnClient.Add Item:=frm, Key:=CStr(frm.Hwnd)

        Set frm = Nothing

    End Function


    How can I add the where condition in my old code to the new function?



    Nath

    Friday, April 21, 2017 9:39 AM

Answers

  • before frm.Visible you can write:
    frm.OpenArgs = "CustomerID=5"

    Then in the Form_Open, inspect OpenArgs and use the Bookmark technique to jump to that record.


    -Tom. Microsoft Access MVP

    • Marked as answer by NaPazz Friday, April 21, 2017 2:57 PM
    Friday, April 21, 2017 1:35 PM

All replies

  • before frm.Visible you can write:
    frm.OpenArgs = "CustomerID=5"

    Then in the Form_Open, inspect OpenArgs and use the Bookmark technique to jump to that record.


    -Tom. Microsoft Access MVP

    • Marked as answer by NaPazz Friday, April 21, 2017 2:57 PM
    Friday, April 21, 2017 1:35 PM
  • Thanks Tom,

    That would work.

    In the end I set the multi form's recordsource to a public function's variable that obtained the record's id. 

    Cheers


    Nath

    Friday, April 21, 2017 3:00 PM