hello all,
Is there a variation of IsLoaded Function for any Access version, from 97 - 2003? So far, my entire Access 97 database vba converts to any recent version through Access 2003; I would like to avoid maintaining more than 1 Access version of design masters solely because of IsLoaded.
Below are 5 variations of creating and calling IsLoaded. The second, an FAQ, seems thorough, but Application.CurrentProject.AllForms is not available in Access 97.
thanks
John
5 variations below - first 2 are faqs
Home > Forums > Programmers > DBMS Packages > Microsoft: Access Other topics > FAQs
Microsoft: Access Other topics FAQ
Forum Search FAQs Links Jobs Whitepapers
Forms
How do I check to see if a form is loaded?
faq181-320
Posted: 5 Dec 00
Public Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function
----
Home > Forums > Programmers > DBMS Packages > Microsoft: Access Forms > FAQs
Microsoft: Access Forms FAQ
Forum Search FAQs Links Jobs Whitepapers
Form Basics
How To Check If A Form Is Loaded?
faq702-5318
Posted: 21 Jul 04
The function below takes the name of a form as an input parameter and returns True/False if the form is loaded.
There is a second optional parameter that allows you to specify (by setting value to True that you want to know whether there
is another form loaded other than the one specified in the first parameter.
Place the code in a module and call it using something like:
If formIsLoaded("MyForm") Then ' MyForm is loaded
If formIsLoaded("MyForm", True) Then ' Some other form other than MyForm is loaded
CODE
'-----------------------------------------------------------
' FUNCTION: formIsLoaded
'
' Determines whether the specified form OR
' another form other than the one specified
' is loaded.
'-----------------------------------------------------------
'
Public Function formIsLoaded(ByVal vstrForm2Check As String, Optional ByVal vblnExcludingForm2Check As Boolean = False) As
Boolean
On Error GoTo Err_formIsLoaded
Dim aobForm As AccessObject
For Each aobForm In Application.CurrentProject.AllForms
If aobForm.IsLoaded Then
If aobForm.name = vstrForm2Check And vblnExcludingForm2Check = False Then
formIsLoaded = True
Exit Function
ElseIf aobForm.name <> vstrForm2Check And vblnExcludingForm2Check = True Then
formIsLoaded = True
Exit Function
End If
End If
Next aobForm
formIsLoaded = False
Exit_formIsLoaded:
Exit Function
Err_formIsLoaded:
MsgBox Err.Description
Resume Exit_formIsLoaded
End Function
----
Public Function IsLoaded(ByVal FormName As String) As Boolean
On Error GoTo Err_IsLoaded
If Forms(FormName).CurrentView <> 0 Then
IsLoaded = True
End If
Exit_IsLoaded:
Exit Function
Err_IsLoaded:
IsLoaded = False
Resume Exit_IsLoaded
End Function
And then change you code to something like
CODE
If IsLoaded("F-36-FORUM") Then
'if the form is open execute this
SQL = "SELECT [T-FORUM].ID, " _
& "FROM [T-FORUM]; "' to nothing, ignore
End If
----
Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet view.
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function
----
Function IsLoaded(FormName)
On Error GoTo Err_IsLoaded
'to call this function, you must put the form in quotes,
'for example: IsLoaded("frmEntries_EntrySelection")
IsLoaded = (SysCmd(SYSCMD_GETOBJECTSTATE, A_FORM, FormName) <> 0)
Exit_IsLoaded:
Exit Function
Err_IsLoaded:
MsgBox Err.Number & ", " & Err.Description
Resume Exit_IsLoaded
End Function
Is there a variation of IsLoaded Function for any Access version, from 97 - 2003? So far, my entire Access 97 database vba converts to any recent version through Access 2003; I would like to avoid maintaining more than 1 Access version of design masters solely because of IsLoaded.
Below are 5 variations of creating and calling IsLoaded. The second, an FAQ, seems thorough, but Application.CurrentProject.AllForms is not available in Access 97.
thanks
John
5 variations below - first 2 are faqs
Home > Forums > Programmers > DBMS Packages > Microsoft: Access Other topics > FAQs
Microsoft: Access Other topics FAQ
Forum Search FAQs Links Jobs Whitepapers
Forms
How do I check to see if a form is loaded?
faq181-320
Posted: 5 Dec 00
Public Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function
----
Home > Forums > Programmers > DBMS Packages > Microsoft: Access Forms > FAQs
Microsoft: Access Forms FAQ
Forum Search FAQs Links Jobs Whitepapers
Form Basics
How To Check If A Form Is Loaded?
faq702-5318
Posted: 21 Jul 04
The function below takes the name of a form as an input parameter and returns True/False if the form is loaded.
There is a second optional parameter that allows you to specify (by setting value to True that you want to know whether there
is another form loaded other than the one specified in the first parameter.
Place the code in a module and call it using something like:
If formIsLoaded("MyForm") Then ' MyForm is loaded
If formIsLoaded("MyForm", True) Then ' Some other form other than MyForm is loaded
CODE
'-----------------------------------------------------------
' FUNCTION: formIsLoaded
'
' Determines whether the specified form OR
' another form other than the one specified
' is loaded.
'-----------------------------------------------------------
'
Public Function formIsLoaded(ByVal vstrForm2Check As String, Optional ByVal vblnExcludingForm2Check As Boolean = False) As
Boolean
On Error GoTo Err_formIsLoaded
Dim aobForm As AccessObject
For Each aobForm In Application.CurrentProject.AllForms
If aobForm.IsLoaded Then
If aobForm.name = vstrForm2Check And vblnExcludingForm2Check = False Then
formIsLoaded = True
Exit Function
ElseIf aobForm.name <> vstrForm2Check And vblnExcludingForm2Check = True Then
formIsLoaded = True
Exit Function
End If
End If
Next aobForm
formIsLoaded = False
Exit_formIsLoaded:
Exit Function
Err_formIsLoaded:
MsgBox Err.Description
Resume Exit_formIsLoaded
End Function
----
Public Function IsLoaded(ByVal FormName As String) As Boolean
On Error GoTo Err_IsLoaded
If Forms(FormName).CurrentView <> 0 Then
IsLoaded = True
End If
Exit_IsLoaded:
Exit Function
Err_IsLoaded:
IsLoaded = False
Resume Exit_IsLoaded
End Function
And then change you code to something like
CODE
If IsLoaded("F-36-FORUM") Then
'if the form is open execute this
SQL = "SELECT [T-FORUM].ID, " _
& "FROM [T-FORUM]; "' to nothing, ignore
End If
----
Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet view.
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function
----
Function IsLoaded(FormName)
On Error GoTo Err_IsLoaded
'to call this function, you must put the form in quotes,
'for example: IsLoaded("frmEntries_EntrySelection")
IsLoaded = (SysCmd(SYSCMD_GETOBJECTSTATE, A_FORM, FormName) <> 0)
Exit_IsLoaded:
Exit Function
Err_IsLoaded:
MsgBox Err.Number & ", " & Err.Description
Resume Exit_IsLoaded
End Function