Runtime error '2450' Microsoft Office Access...

  • Thread starter ragtopcaddy via AccessMonster.com
  • Start date
R

ragtopcaddy via AccessMonster.com

...can't find the form, 'frmRptStores' referred to in a macro expression or
visual basic code.

I definitely have the form, 'frmRptStores' amongst my forms. In fact, DoCmd.
OpenForm "frmRptStores" successfully opens the form. But the following line
fails:

Set Frm = Forms("frmRptStores")

The frm variable is set as follows:

Dim Frm As New Access.Form

Any help would be appreciated
 
R

ragtopcaddy via AccessMonster.com

OK, I placed the following code in the module:

For Each Frm In Forms
Debug.Print Frm.Name
Next Frm

It only prints the name of one of the three forms have in the database
project. All 3 forms are visible in the project window, and docmd.openform
will open all 3 of them.

I am running this code from behind a command button on another form (the form
whose name prints when I run the above loop).
 
R

ragtopcaddy via AccessMonster.com

Thanks a million, Tom.

I will try that. Funny, I don't remember that as being essential. Isn't the
forms collection always accessible?


Tom said:
Hi Bill,

Your form frmRptStores needs to be open when you run that code. It can be
opened in hidden mode, but it needs to be open. If it is closed, you will
generate the error that you are seeing.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
...can't find the form, 'frmRptStores' referred to in a macro expression or
visual basic code.
[quoted text clipped - 10 lines]
Any help would be appreciated

--
Bill Reed

"If you can't laugh at yourself, laugh at somebody else"

Message posted via AccessMonster.com
 
R

ragtopcaddy via AccessMonster.com

OK, that worked. Now it prints the 2 names and I am able to set the variable
to it. I have opened it hidden. Is there a simple way to unhide it after
setting its recordsource, or do I have to close it and reopen it normal.

Thanks,

Bill
 
T

Tom Wickerath

Isn't the forms collection always accessible?

No. Here are two variations that you can use. I based the second subrouting,
EnumerateAllForms, on Access MVP Arvin Meyer's code for saving all objects to
external text files:

http://www.datastrat.com/Code/DocDatabase.txt


Option Compare Database
Option Explicit

Sub EnumerateOpenForms()

Dim Frm As Access.Form

For Each Frm In Forms
Debug.Print Frm.Name
Next Frm

End Sub


Sub EnumerateAllForms()

Dim db As DAO.Database
Dim cnt As DAO.Container
Dim doc As DAO.Document

Set db = CurrentDb
Set cnt = db.Containers("Forms")

For Each doc In cnt.Documents
Debug.Print doc.Name
Next doc

Set db = Nothing
End Sub


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
R

ragtopcaddy via AccessMonster.com

Thanks, Tom,

That worked just fine!

Tom said:
Sure, just use the Openform method of the DoCmd object. This works even if
the form is alreay open in hidden mode. No need to close the form first:

DoCmd.Openform "NameOfForm"


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
OK, that worked. Now it prints the 2 names and I am able to set the variable
to it. I have opened it hidden. Is there a simple way to unhide it after
[quoted text clipped - 3 lines]
 
Joined
Oct 9, 2008
Messages
2
Reaction score
0
One can dowload a sample database customsecurity.zip from http://www.access-programmers.co.uk/forums/showthread.php?p=687779.

In the code control cmdStatTrackAdminin the form frmStartUp is reffered from form frmSignIn without opening frmStartUp first in hidden mode:
Forms!frmStartUp!cmdStatTrackAdmin.Enabled = True
Forms!frmStartUp!cmdAppAdmin.Enabled = True

It works well here, no error is brought up. Can someone explain why? In my other cases such referring brings up error 2450.

Regards, R
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top