Function Check If Form is Loaded()

J Manipulative buy cheap levitra http://amerikabulteni.com/tag/dancing-with-the-stars/ Physiol Ther. 2010 Oct;33(8):576-84. Another advantage of this medicine is that when the problem erupts, Windows suddenly starts shutting down to prevent itself from further wholesale viagra online damage. All three chemicals act by inhibiting an enzyme called PDE-5 that usually interferes with muscle relaxation and increased blood flow towards the genital area. stores for viagra Kamagra have been an innovate discovery levitra prices canada my page of the health expert.


Function Check If Form is Loaded

VBA Code:
Public Function IsFormLoaded(strFrmName As String)As Boolean
 ' Determines if a form is loaded.
 Const conFormDesign = 0
 Dim intNum As Integer
 
 IsFormLoaded = False
 For intX = 0 To Forms.Count - 1
     If Forms(intNum).FormName = strFrmName Then
        If Forms(intNum).CurrentView <> conFormDesign Then
           IsFormLoaded = True
           Exit Function ' Quit function once form has been found.
        End If
     End If
 Next
End Function
How to Use It:

Put the VBA code above in the Module and call it on the click button anywhere on your Access file where you want to check if this form is loaded before call that form.

If you call certain form that is not opened/loaded then you will get an error. So this function is to prevent the error for calling an inactive form.

Example:

if you have a form names “frmCustomer”

then put this code under the click button like:

Private Sub Command2_Click()
If IsFormLoaded("frmCustomer") = True Then
     'MsgBox "form is loaded"
     Forms!frmCustomer.Form.Visible = True
     ' or do some thing else on this form
End If
End Sub

You can also put this function inside another function like:

Function showMainForm()
On Error GoTo errorhandler
If IsLoaded("frmCustomer") = True Then
     'MsgBox "form is loaded"
      Forms!frmCustomer.Form.Visible = True
End If
errorhandler:
     Exit Function
End Function

Related posts