I’ve tried –
For each frm in Forms
debug.print frm.name
Next
But of course this only finds forms which are currently open.
How do I list all forms even if they are closed?
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Listing Forms in an Application
In order to do that you need to refer to the AllForms Collection. See MSDN AllForms Collection for the details and an example of exactly how to list all forms in a database or a project. It is specific to Access 2003 but other version work in a similar fashion.
In order to do that you need to refer to the AllForms Collection. See MSDN AllForms Collection for the details and an example of exactly how to list all forms in a database or a project. It is specific to Access 2003 but other version work in a similar fashion.
Thanks Wendell, that’s what I wanted.
In order to do that you need to refer to the AllForms Collection. See MSDN AllForms Collection for the details and an example of exactly how to list all forms in a database or a project. It is specific to Access 2003 but other version work in a similar fashion.
I’m having problems trying to find the desctription property of the form.
I’m using the name of the allforms object to open the form and I can then get all the other properties but I just can’t find the description.
Try the example shown in MSDN Properties Collection – it should enumerate the properties of a form if you have one open, and give you the name of each property.
Try the example shown in MSDN Properties Collection – it should enumerate the properties of a form if you have one open, and give you the name of each property.
Thanks Wendell but I’d already iterated throught the properties collection, but the Description if not there.
I’ve checked both the properties of AllForms and of open forms. No Description property.
Any ideas as to where else I might find it?
Here is a function that will return the Description property of a form. I found this Here
Function FormDescription(FormName As String, Optional DefaultDescription = Empty, Optional ClearDescription As Boolean = False) As String Dim loDb As DAO.Database Dim loForm As DAO.Document Dim loProp As DAO.Property Dim strRet As String On Error GoTo FormDescription_err Const PROP_NAME_DESCRIPTION = "Description" Const CONTAINER_FORMS = "Forms" strRet = vbNullString Set loDb = CurrentDb Set loForm = loDb.Containers(CONTAINER_FORMS).Documents(FormName) If Not ClearDescription Then strRet = loForm.Properties(PROP_NAME_DESCRIPTION) Else On Error Resume Next With loForm.Properties .Delete PROP_NAME_DESCRIPTION .Refresh End With On Error GoTo FormDescription_err End If FormDescription_end: On Error Resume Next Set loForm = Nothing Set loDb = Nothing Set loProp = Nothing FormDescription = strRet Exit Function FormDescription_err: Select Case Err Case 3265 'Item not found in this collection. MsgBox "The form " & FormName & " does not exist." Case 3270 'Property not found. If IsEmpty(DefaultDescription) Then strRet = vbNullString Else If Len(DefaultDescription) > 0 Then With loForm Set loProp = .CreateProperty(PROP_NAME_DESCRIPTION, dbText, DefaultDescription) With .Properties .Append loProp .Refresh End With End With Resume Else strRet = vbNullString End If End If Case Else MsgBox Err.Description End Select Resume FormDescription_end End Function
Then this will loop through each form in Allforms, print its name and Description.
Private Sub Command70_Click() Dim strDescription As String 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 Debug.Print obj.Name strDescription = FormDescription(obj.Name) Debug.Print strDescription Next obj End Sub
Here is a function that will return the Description property of a form. I found this Here
Code:Function FormDescription(FormName As String, Optional DefaultDescription = Empty, Optional ClearDescription As Boolean = False) As String Dim loDb As DAO.Database Dim loForm As DAO.Document Dim loProp As DAO.Property Dim strRet As String On Error GoTo FormDescription_err Const PROP_NAME_DESCRIPTION = "Description" Const CONTAINER_FORMS = "Forms" strRet = vbNullString Set loDb = CurrentDb Set loForm = loDb.Containers(CONTAINER_FORMS).Documents(FormName) If Not ClearDescription Then strRet = loForm.Properties(PROP_NAME_DESCRIPTION) Else On Error Resume Next With loForm.Properties .Delete PROP_NAME_DESCRIPTION .Refresh End With On Error GoTo FormDescription_err End If FormDescription_end: On Error Resume Next Set loForm = Nothing Set loDb = Nothing Set loProp = Nothing FormDescription = strRet Exit Function FormDescription_err: Select Case Err Case 3265 'Item not found in this collection. MsgBox "The form " & FormName & " does not exist." Case 3270 'Property not found. If IsEmpty(DefaultDescription) Then strRet = vbNullString Else If Len(DefaultDescription) > 0 Then With loForm Set loProp = .CreateProperty(PROP_NAME_DESCRIPTION, dbText, DefaultDescription) With .Properties .Append loProp .Refresh End With End With Resume Else strRet = vbNullString End If End If Case Else MsgBox Err.Description End Select Resume FormDescription_end End FunctionThen this will loop through each form in Allforms, print its name and Description.
Code:Private Sub Command70_Click() Dim strDescription As String 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 Debug.Print obj.Name strDescription = FormDescription(obj.Name) Debug.Print strDescription Next obj End Sub
Well that’s just fantastic. I’d googled my little fingers to the bone and couldn’t find anything.
This does the job. A very big THANKYOU!!
Kent
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications