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 ;-) 7 7193
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 ;-)
"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)
"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
"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)
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 ;-)
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
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) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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"...
|
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...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |