backcountryprogrammer
Member
- Local time
- Today, 13:34
- Joined
- Aug 10, 2024
- Messages
- 39
Hello,
The key in the Forms object for forms opened from the interface is the name of the form (see Case1).
When I dynamically create a form it is also added to the Forms object. However, the key used to add the dynamic form is obviously not the form's name (see Case2). It seems that Access/VBA generates a unique key to avoid collisions. Unfortunately, there seems to be no way to read out the keys in the Forms object. Does somebody know how this key is constructed? Is this somewhere documented?
The key in the Forms object for forms opened from the interface is the name of the form (see Case1).
When I dynamically create a form it is also added to the Forms object. However, the key used to add the dynamic form is obviously not the form's name (see Case2). It seems that Access/VBA generates a unique key to avoid collisions. Unfortunately, there seems to be no way to read out the keys in the Forms object. Does somebody know how this key is constructed? Is this somewhere documented?
Code:
Sub Case1()
' Form1 opened from interface.
Debug.Assert CurrentProject.AllForms("Form1").IsLoaded
Debug.Print Forms("Form1").Name
End Sub
Sub Case2()
Debug.Assert Not CurrentProject.AllForms("Form1").IsLoaded
Dim f As New Form_Form1
Debug.Print Forms(f.Name).Name ' Run-time error 2450
End Sub