Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Form close/reopen to filter criteria

Posted on 2011-04-27
4
Medium Priority
?
371 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:pdvsa
  • 2
4 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 35476732
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
0
 
LVL 77

Expert Comment

by:peter57r
ID: 35476739
Obviously you must use your own control names in the above mod.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 35477416
try this, better to check the value of .filter property of the form

Private Sub btnOpenLCForm_Click()

    If CurrentProject.AllForms("frmLetterOfCredit_Cont").IsLoaded = False Then
         DoCmd.OpenForm "frmLetterOfCredit_Cont", , , , , , OpenArgs:=Me.ID & ";" & Me.cboEndUserID
        'Cancel = True
    Else
    
        If Forms!frmLetterOfCredit_Cont.Filter = "[ProjectID] = " & Me.ID & " AND [EndUserID] = " & Me.cboEndUserID Then
            Forms!frmLetterOfCredit_Cont.SetFocus
            Else
            DoCmd.Close acForm, "frmLetterOfCredit_Cont"
            DoCmd.OpenForm "frmLetterOfCredit_Cont", , , , , , OpenArgs:=Me.ID & ";" & Me.cboEndUserID
        End If
    End If

End sub

Open in new window

0
 

Author Comment

by:pdvsa
ID: 35478490
Cap, that worked perfectly.  I was just about to respond to Peter.

Pdvsa
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When we develop an application in Ms Access 2016 we should also try to protect the queries, macros and table links. I know I may not have a permanent solution but for novice users, they will not manage to break your application. Below is the detail …
A Case Study of using the Windows API to provide RS232 communications capability in Access without the use of Active-X controls.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question