EL_Gringo
Member
- Local time
- Today, 02:03
- Joined
- Aug 22, 2012
- Messages
- 38
No matter how, I cannot get Set frm = Forms(FormName) to work. Though used in uncountable solutions, I'm stonewalled by Error 13, Type mismatch or Error 438, Object doesn't support this property or method. What works:
Private Sub Test_Click()
ListControlProps Me
End Sub
Public Sub ListControlProps(ByRef frm As Form)
Set CurrDB = CurrentDb()
For Each ctl In frm.Controls
...
Any other attempt to assign another form (i.e. not the current form using 'me') to a variable throws an error. For open forms (in normal or design view) and using the Forms-Collection:
Dim frm As Form 'Or Access.Form
Dim FormName As String
FormName = "MyExistingForm"
DoCmd.OpenForm FormName, acDesign, , , , acHidden
Set frm = Forms(FormName) 'Error 438
For closed forms and using the AllForms-Collection I tried:
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
Dim FormName As String
Dim frm As Form 'Or Access.Form
For Each obj In dbs.AllForms
If obj.IsLoaded = False Then
With obj
FormName = .Name
Debug.Print "Form Name: " & .Name
Set frm = Forms(FormName) 'Error 438
Set frm = dbs.AllForms(FormName) 'Error 13, Type mismatch
Set frm = obj 'Error 13, Type mismatch
Set frm = .Name 'Type mismatch at Debug
End With
End If
Next obj
What am I missing? Do I need to activate a special Reference for VBA?
I'm working with Access 2013 Professional Plus on Windows 10, all up to date.
Private Sub Test_Click()
ListControlProps Me
End Sub
Public Sub ListControlProps(ByRef frm As Form)
Set CurrDB = CurrentDb()
For Each ctl In frm.Controls
...
Any other attempt to assign another form (i.e. not the current form using 'me') to a variable throws an error. For open forms (in normal or design view) and using the Forms-Collection:
Dim frm As Form 'Or Access.Form
Dim FormName As String
FormName = "MyExistingForm"
DoCmd.OpenForm FormName, acDesign, , , , acHidden
Set frm = Forms(FormName) 'Error 438
For closed forms and using the AllForms-Collection I tried:
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
Dim FormName As String
Dim frm As Form 'Or Access.Form
For Each obj In dbs.AllForms
If obj.IsLoaded = False Then
With obj
FormName = .Name
Debug.Print "Form Name: " & .Name
Set frm = Forms(FormName) 'Error 438
Set frm = dbs.AllForms(FormName) 'Error 13, Type mismatch
Set frm = obj 'Error 13, Type mismatch
Set frm = .Name 'Type mismatch at Debug
End With
End If
Next obj
What am I missing? Do I need to activate a special Reference for VBA?
I'm working with Access 2013 Professional Plus on Windows 10, all up to date.