Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Unable to set a form object

Posted on 2007-10-19
3
Medium Priority
?
235 Views
Last Modified: 2013-11-27
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.
0
Comment
Question by:alk10
  • 2
3 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 20109426
>The form is named correctly and exists.
It also has to be open in order for it to appear in the Forms() collection.
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 20109441
Do this in your Immediate Window:

?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.
0
 

Author Comment

by:alk10
ID: 20109534
I didn't realize the form had to be open.

Thank you.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have had my own IT business for a very long time. I started mostly with hardware and after about a year started to notice a common theme. I had shelves with software boxes -- Peachtree, Quicken, Sage, Ouickbooks -- and yet most of my clients were…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question