472,374 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 software developers and data experts.

Application can't find opened form???

Can someone please explain why the following code
raises error 2450?...
Note:
frmTest is a simple form with code behind form so it
can be instantiated through the form's class module.

Public Sub sbTest()
On Error GoTo errHandler
Dim frm As Access.Form

'create new instance of the class Form_frmTest
Set frm = New Form_frmTest
'make form visible
frm.Visible = True
'get form's name
MsgBox Forms("frmTest").Name 'err 2450 is generated here. Why?...

bye:
Set frm = Nothing
Exit Sub
errHandler:
Select Case Err
Case 2450 'can't find form
MsgBox "What is hapening here!???..." & vbCrLf & "Can't find this
form???"
Case Else
MsgBox Err() & vbCrLf & Error$()
End Select
Resume bye
End Sub

Thanks for ANY input ,
---
(-: a s i l b a . p t ;-)
Nov 12 '05 #1
7 7039
TC
Just as a matter of interest, why are you opening the form with New, instead
of using OpenForm? When you use OpenForm, the form certainly is added to the
Forms collection...

HTH,
TC
"a s i l b a . p t" <as*******************@hotmail.com> wrote in message
news:3f*********************@news.telepac.pt...
Can someone please explain why the following code
raises error 2450?...
Note:
frmTest is a simple form with code behind form so it
can be instantiated through the form's class module.

Public Sub sbTest()
On Error GoTo errHandler
Dim frm As Access.Form

'create new instance of the class Form_frmTest
Set frm = New Form_frmTest
'make form visible
frm.Visible = True
'get form's name
MsgBox Forms("frmTest").Name 'err 2450 is generated here. Why?...

bye:
Set frm = Nothing
Exit Sub
errHandler:
Select Case Err
Case 2450 'can't find form
MsgBox "What is hapening here!???..." & vbCrLf & "Can't find this
form???"
Case Else
MsgBox Err() & vbCrLf & Error$()
End Select
Resume bye
End Sub

Thanks for ANY input ,
---
(-: a s i l b a . p t ;-)

Nov 12 '05 #2
"TC" <a@b.c.d> wrote in news:1068341629.447304@teuthos:
Just as a matter of interest, why are you opening the form with New,
instead of using OpenForm? When you use OpenForm, the form certainly is
added to the Forms collection...

HTH,
TC
"a s i l b a . p t" <as*******************@hotmail.com> wrote in message
news:3f*********************@news.telepac.pt...
Can someone please explain why the following code
raises error 2450?...
Note:
frmTest is a simple form with code behind form so it
can be instantiated through the form's class module.

Public Sub sbTest()
On Error GoTo errHandler
Dim frm As Access.Form

'create new instance of the class Form_frmTest
Set frm = New Form_frmTest
'make form visible
frm.Visible = True
'get form's name
MsgBox Forms("frmTest").Name 'err 2450 is generated here. Why?...

bye:
Set frm = Nothing
Exit Sub
errHandler:
Select Case Err
Case 2450 'can't find form
MsgBox "What is hapening here!???..." & vbCrLf & "Can't find
this
form???"
Case Else
MsgBox Err() & vbCrLf & Error$()
End Select
Resume bye
End Sub

Thanks for ANY input ,
---
(-: a s i l b a . p t ;-)


If we use the DoCmd object only one instance of the form is opened. So
Access has no problem finding Forms("NameofForm").

But if we open the form by instantiating its class, we can have multiple
copies of a form, and Access, quite properly IMO, recognizes the potential
for multiple instances of forms with the same name, and declines to allow
index reference by name to these forms, or even these forms.

Code below to illustrate.

Sub temp()
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
Debug.Print Forms.Count '1
Debug.Print Forms("Form1").Name 'Form1
DoCmd.Close acForm, "Form1"
End Sub

Sub temp2()
Dim frm(9) As Form_Form1
Dim z As Long
For z = 0 To 9
Set frm(z) = New Form_Form1
frm(z).Visible = True
Debug.Print frm(z).Name
Next z
Erase frm
End Sub

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #3
TC

"Lyle Fairfield" <Mi************@Invalid.Com> wrote in message
news:Xn*******************@130.133.1.4...
"TC" <a@b.c.d> wrote in news:1068341629.447304@teuthos:
Just as a matter of interest, why are you opening the form with New,
instead of using OpenForm? When you use OpenForm, the form certainly is
added to the Forms collection...

HTH,
TC
"a s i l b a . p t" <as*******************@hotmail.com> wrote in message
news:3f*********************@news.telepac.pt...
Can someone please explain why the following code
raises error 2450?...
Note:
frmTest is a simple form with code behind form so it
can be instantiated through the form's class module.

Public Sub sbTest()
On Error GoTo errHandler
Dim frm As Access.Form

'create new instance of the class Form_frmTest
Set frm = New Form_frmTest
'make form visible
frm.Visible = True
'get form's name
MsgBox Forms("frmTest").Name 'err 2450 is generated here. Why?...

bye:
Set frm = Nothing
Exit Sub
errHandler:
Select Case Err
Case 2450 'can't find form
MsgBox "What is hapening here!???..." & vbCrLf & "Can't find
this
form???"
Case Else
MsgBox Err() & vbCrLf & Error$()
End Select
Resume bye
End Sub

Thanks for ANY input ,
---
(-: a s i l b a . p t ;-)


If we use the DoCmd object only one instance of the form is opened. So
Access has no problem finding Forms("NameofForm").

But if we open the form by instantiating its class, we can have multiple
copies of a form, and Access, quite properly IMO, recognizes the potential
for multiple instances of forms with the same name, and declines to allow
index reference by name to these forms, or even these forms.

Code below to illustrate.

Sub temp()
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
DoCmd.OpenForm "Form1"
Debug.Print Forms.Count '1
Debug.Print Forms("Form1").Name 'Form1
DoCmd.Close acForm, "Form1"
End Sub

Sub temp2()
Dim frm(9) As Form_Form1
Dim z As Long
For z = 0 To 9
Set frm(z) = New Form_Form1
frm(z).Visible = True
Debug.Print frm(z).Name
Next z
Erase frm
End Sub

Ok, thanks for the info. I thought it might be that, but was not sure. I
assume the point of Sub temp2(), is that none of those form instances will
appear in the Forms collection? (you are showing their names from their
instance references, but not from the Forms collecion)

TC

Nov 12 '05 #4
"TC" <a@b.c.d> wrote in news:1068344395.768084@teuthos:
Ok, thanks for the info. I thought it might be that, but was not sure. I
assume the point of Sub temp2(), is that none of those form instances will
appear in the Forms collection? (you are showing their names from their
instance references, but not from the Forms collecion)

TC


They'll all be items in the forms collection. But they all have the same name
so to reference them individually it seems one needs to use a numeric
reference.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #5
Your code works for me, as long as it is called from a command button on frmTest. This is
similar to the example shown in MSKB 210248:

http://support.microsoft.com/default...b;en-us;210248

If I attempt to run your code by itself, in a stand alone module, I can see frmTest open
but I also get the same error 2450 that you are getting. I can send you a sample DB that
works on my PC if you want me to.

Tom

____________________________________________

"a s i l b a . p t" <as*******************@hotmail.com> wrote in message
news:3f*********************@news.telepac.pt...

Can someone please explain why the following code
raises error 2450?...
Note:
frmTest is a simple form with code behind form so it
can be instantiated through the form's class module.

Public Sub sbTest()
On Error GoTo errHandler
Dim frm As Access.Form

'create new instance of the class Form_frmTest
Set frm = New Form_frmTest
'make form visible
frm.Visible = True
'get form's name
MsgBox Forms("frmTest").Name 'err 2450 is generated here. Why?...

bye:
Set frm = Nothing
Exit Sub
errHandler:
Select Case Err
Case 2450 'can't find form
MsgBox "What is hapening here!???..." & vbCrLf & "Can't find this
form???"
Case Else
MsgBox Err() & vbCrLf & Error$()
End Select
Resume bye
End Sub

Thanks for ANY input ,
---
(-: a s i l b a . p t ;-)

Nov 12 '05 #6
Hi all,

I also tried this:
-- if you run the code by itself, in a stand alone module it also works ... when frmtest is open

Arno R
"Tom Wickerath" <AO***********************@comcast.net> schreef in bericht
news:Dv********************@comcast.com...
Your code works for me, as long as it is called from a command button on frmTest. This is
similar to the example shown in MSKB 210248:

http://support.microsoft.com/default...b;en-us;210248

If I attempt to run your code by itself, in a stand alone module, I can see frmTest open
but I also get the same error 2450 that you are getting. I can send you a sample DB that
works on my PC if you want me to.

Tom


Nov 12 '05 #7
I can perfectly understand Mr. Lyle's point of view,
though I do think It would be reasonable to expect
referencing the form by name would not error,
since only one form is added to the forms collection.
Anyway, I just turned around this issue,
by using a numeric reference to the form instance,
as sugested.

Thank you ALL for the valid input!
---
(-: a s i l b a . p t ;-)

"Lyle Fairfield" <Mi************@Invalid.Com> wrote in message
news:Xn*******************@130.133.1.4...
"TC" <a@b.c.d> wrote in news:1068344395.768084@teuthos:
Ok, thanks for the info. I thought it might be that, but was not sure. I
assume the point of Sub temp2(), is that none of those form instances will appear in the Forms collection? (you are showing their names from their
instance references, but not from the Forms collecion)

TC
They'll all be items in the forms collection. But they all have the same

name so to reference them individually it seems one needs to use a numeric
reference.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)

Nov 12 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ron L | last post by:
I have an MDI application which opens a number of child windows, each of which could have data in a state that needs to be saved. Each child window catches its Closing event and cancels it if the...
2
by: Flo | last post by:
Hello I want to be able to show/hide an application that is running. When i am getting the handles corresponding to an MS Office application (Excel for example), it appears that i get a handle...
7
by: Paul | last post by:
Hi I have a web application that has a log off selection, just redirects the browser to a form with a label displaying you are loging off. In part of the application I open a new window and was...
9
by: Nathan Sokalski | last post by:
I am trying to connect to a Microsoft Access Database from my ASP.NET Application. I use the following code to create my connection string: cmdSelect.Connection = New...
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
3
by: ApexData | last post by:
Hello I completed an application that worked great until I went to STARTUP and shut off all of the checkboxes. My code uses "Application.CurrentObjectName" to get the current Form name. All my...
4
by: Andrus | last post by:
I have WinForms MDI application. MDI child forms are created by menustrip click enent handler AppDesktop.FormMgr.Show(new ChildForm1("param1", "param2") ); Every MDI child form "childform1"...
2
by: aagarwal8 | last post by:
Hi, I have a chat application which i have created using WinForms 2.0 (C# lang). The situation i am faced with is that i need to close all the opened (chat, public chat, chat invite, chat...
7
by: mxdevit | last post by:
Task: run application from ASP.NET for example, you have a button on ASP.NET page, when press this button - one application is invoked. the code to run application (for example, notepad) is...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.