Created
November 8, 2016 19:17
-
-
Save orellabac/020ac3a22884a24de78af2379ab1f0ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Compare Database | |
Sub AllForms() | |
Dim obj As AccessObject, dbs As Object | |
Set dbs = Application.CurrentProject | |
' Search for open AccessObject objects in AllForms collection. | |
For Each obj In dbs.AllForms | |
If obj.IsLoaded = True Then | |
' Print name of obj. | |
Debug.Print obj.Name | |
fEnumControls (obj.Name) | |
End If | |
Next obj | |
End Sub | |
Function fIsLoaded(ByVal strFormName As String) As Integer | |
'Returns a 0 if form is not open or a -1 if Open | |
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then | |
If Forms(strFormName).CurrentView <> 0 Then | |
fIsLoaded = True | |
End If | |
End If | |
End Function | |
'************ Code Start *************** | |
' This code was originally written by Dev Ashish. | |
' It is not to be altered or distributed, | |
' except as part of an application. | |
' You are free to use it in any application, | |
' provided the copyright notice is left unchanged. | |
' | |
' Code Courtesy of | |
' Dev Ashish | |
' | |
Function fEnumControls(ByVal strfrmToEnum As String) | |
'prints out control's Type and Name | |
'will NOT enumerate controls within an embedded subform | |
Dim astrCtlName() As String | |
Dim i As Integer, intCnt As Integer | |
Dim frm As Form | |
'Un-Comment the next two lines for Access 95 | |
'Const acPage = 124 | |
'Const acTabCtl = 123 | |
'if form is closed, exit function | |
Set frm = Forms(strfrmToEnum) | |
'Count the number of controls | |
intCnt = frm.Count | |
'Initialize the array to hold control names | |
ReDim astrCtlName(0 To intCnt - 1, 0 To 1) | |
For i = 0 To intCnt - 1 | |
astrCtlName(i, 0) = frm(i).Name | |
'Use ControlType to determine the Type of Control | |
Select Case frm(i).ControlType | |
Case acLabel: astrCtlName(i, 1) = "Label" | |
Case acRectangle: astrCtlName(i, 1) = "Rectangle" | |
Case acLine: astrCtlName(i, 1) = "Line" | |
Case acImage: astrCtlName(i, 1) = "Image" | |
Case acCommandButton: astrCtlName(i, 1) = "Command Button" | |
Case acOptionButton: astrCtlName(i, 1) = "Option button" | |
Case acCheckBox: astrCtlName(i, 1) = "Check box" | |
Case acOptionGroup: astrCtlName(i, 1) = "Option group" | |
Case acBoundObjectFrame: astrCtlName(i, 1) = "Bound object frame" | |
Case acTextBox: astrCtlName(i, 1) = "Text Box" | |
Case acListBox: astrCtlName(i, 1) = "List box" | |
Case acComboBox: astrCtlName(i, 1) = "Combo box" | |
Case acSubform: astrCtlName(i, 1) = "SubForm" | |
Case acObjectFrame: astrCtlName(i, 1) = "Unbound object frame or chart" | |
Case acPageBreak: astrCtlName(i, 1) = "Page break" | |
Case acPage: astrCtlName(i, 1) = "Page" | |
Case acCustomControl: astrCtlName(i, 1) = "ActiveX (custom) control" | |
Case acToggleButton: astrCtlName(i, 1) = "Toggle Button" | |
Case acTabCtl: astrCtlName(i, 1) = "Tab Control" | |
End Select | |
Next i | |
'Print out the array in an orderly fashion | |
Debug.Print "Control Name", "Control Type" | |
Debug.Print "------------", "------------" | |
For i = 0 To intCnt - 1 | |
Debug.Print astrCtlName(i, 0), astrCtlName(i, 1) | |
Next i | |
Erase astrCtlName | |
End Function | |
'************ Code End *************** | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment