alk10
asked on
Unable to set a form object
I have a really weird problem. I want to set a form object. My code is
Dim frm As Form
Set frm = Forms("frm_Enquiry")
I'm getting "Run-time error '2450': Microsoft Access can't find the form 'frm_Enquiry' referred in the macro expression or Visual Basic code."
The form is named correctly and exists.
If I use the following syntax, it works:
Dim frm As Form
Set frm = Form_frm_Enquiry
But utiimately, I want to be able to enumerate to all the forms in my database and the latter syntax won't work for me.
Thanks for any help.
Dim frm As Form
Set frm = Forms("frm_Enquiry")
I'm getting "Run-time error '2450': Microsoft Access can't find the form 'frm_Enquiry' referred in the macro expression or Visual Basic code."
The form is named correctly and exists.
If I use the following syntax, it works:
Dim frm As Form
Set frm = Form_frm_Enquiry
But utiimately, I want to be able to enumerate to all the forms in my database and the latter syntax won't work for me.
Thanks for any help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I didn't realize the form had to be open.
Thank you.
Thank you.
?Forms.Count 'This returns the number of open forms.
?Forms(0).Name 'This returns the first open form's name
?Forms(1).Name 'This returns the second open form's name, etc.