Link to home
Start Free TrialLog in
Avatar of pdvsa
pdvsaFlag for United States of America

asked on

Form close/reopen to filter criteria

Experts,
In the below code I woudl like to know if under the ELSE part I can add something that looks to see if the open form "frmLetterOfCredit_Cont" is already opened to the filter criteria and if so then dont reopen it like it is doing now?  If the form is already open to the filter criteria currently it closes and then reopens and it takes too much time because the network is slow.  

So basically if the form "frmLetterOfCredit_Cont" is already opened to OpenArgs:=Me.ID & ";" & Me.cboEndUserID then dont close it and reopen...just bring that form to the front and if NOT then close and reopen.

Private Sub btnOpenLCForm_Click()

    If CurrentProject.AllForms("frmLetterOfCredit_Cont").IsLoaded = False Then
         DoCmd.OpenForm "frmLetterOfCredit_Cont", , , , , , OpenArgs:=Me.ID & ";" & Me.cboEndUserID
        'Cancel = True
    Else
        DoCmd.Close acForm, "frmLetterOfCredit_Cont"
        DoCmd.OpenForm "frmLetterOfCredit_Cont", , , , , , OpenArgs:=Me.ID & ";" & Me.cboEndUserID

    End If
   
End Sub
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

If CurrentProject.AllForms("frmLetterOfCredit_Cont").IsLoaded = False Then
         DoCmd.OpenForm "frmLetterOfCredit_Cont", , , , , , OpenArgs:=Me.ID & ";" & Me.cboEndUserID
        'Cancel = True

elseif forms!frmletterofcredit.someidcontrol= me.id and forms!frmletterofcredit.anotheridcontrol= Me.cboEndUserID then
' do nothing, already correct

Else
        DoCmd.Close acForm, "frmLetterOfCredit_Cont"
        DoCmd.OpenForm "frmLetterOfCredit_Cont", , , , , , OpenArgs:=Me.ID & ";" & Me.cboEndUserID
End If
Obviously you must use your own control names in the above mod.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdvsa

ASKER

Cap, that worked perfectly.  I was just about to respond to Peter.

Pdvsa