Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jul 2002
    Cedar Falls, Iowa, USA
    Thanked 0 Times in 0 Posts

    conditional Set frm (A2003)

    I have a form I use to edit/add to a combo box. The combo box is on several different subforms. Is there a way to capture which subform lauched the edit/add form (via cmd btn) and then use that information to define the "Set frm" in the code below?

    As a work around I created 4 different versions of the edit/add form and customized the Close code to each individual subform, but it seems terribly inefficient. You can see in the code below where I've commented out the other subforms which also call the edit/add form.

    Any ideas?


    Private Sub Form_Close()

    Dim frm As Form
    Set frm = Forms!frmConsumer!fsubAddrHm.Form
    'Set frm = Forms!frmEnterConsumer!fsubAddrHm.Form
    'Set frm = Forms!frmEnterOrg!fsubAddrMlg.Form
    'Set frm = Forms!frmOrg!fsubAddr

    frm.RecordsetClone.FindFirst "[lngcszID] = " & frm![cboCSZID]
    frm.Bookmark = frm.RecordsetClone.Bookmark

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: conditional Set frm (A2003)

    You could define a global variable in a standard module:

    Public frmCaller As Form

    Set this variable in the code that opens the edit/add form, for example:

    Set frmCaller = Forms!frmConsumer!fsubAddrHm.Form
    DoCmd.OpenForm ...

    and use it in the On Close event of the edit/add form:

    frmCaller.RecordsetClone.FindFirst "[lngcszID] = " & frmCaller![cboCSZID]
    frmCaller.Bookmark = frmCaller.RecordsetClone.Bookmark

Posting Permissions

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