Error Code 2450 (1 Viewer)

PatAccess

Registered User.
Local time
Today, 03:15
Joined
May 24, 2017
Messages
284
Good day all my smart people,

I need some help. First, please know that I have been working on finding a solution to this all weekend and read ALL the threads on this site on the following subject.

Here is the code I have:
Private Sub Form_Load()
If Me.Dirty = True Then Me.Dirty = False
Me.HomeFixtures = Forms!Frm_HomeFixtures!TextPriceTotal
End Sub

I get Error Code 2450 and it says it cannot find Frm_HomeFixtures. Most thread I've read are telling me the form as to be open or giving other information about opening the form. I do not want to open the form. I want the field [HomeFixtures] = Forms!Frm_HomeFixtures!TextPriceTotal. Simple. How can I do that please :banghead::banghead:

Thank you
 

Minty

AWF VIP
Local time
Today, 08:15
Joined
Jul 26, 2013
Messages
10,371
Simple - open the form.
Until the form is open that control doesn't exist and won't have any context or value, so setting your current forms value to it would be meaningless.

If that form has a value set by some table or query, use the same source to set your value using a DLookup.
 

PatAccess

Registered User.
Local time
Today, 03:15
Joined
May 24, 2017
Messages
284
So is there a way to open that form on the back end?
The field [HomeFixtures] is an unbound field within my form that calculates several value and I need to transfer that value into another form.
 

jdraw

Super Moderator
Staff member
Local time
Today, 03:15
Joined
Jan 23, 2006
Messages
15,378
I am confused with the Forms!Frm_HomeFixtures and field [HomeFixtures].

Fields are in tables, controls are on forms.
Forms are in the front end, they can be populated with data from the backend (table(s).

The 2450 seems to indicate an attempt to use info on a form that is not open or doesn't exist.

Please tell us more or post a couple of jpgs to clarify your requirement and set up.
What are you trying to do in plain English?
 

Minty

AWF VIP
Local time
Today, 08:15
Joined
Jul 26, 2013
Messages
10,371
No - there shouldn't be any forms in your backend database. (That's not strictly true but it is for the purposes of this conversation)

On the form Frm_HomeFixtures , how does TextPriceTotal get it's value?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:15
Joined
May 7, 2009
Messages
19,233
You can open it for a while then immediately closed it when you got what you want. Otherwise some spikepl will catch us for our inefficient code:


Private Sub Form_Load()
Dim frm as form
Set frm=Form_Frm_HomeFixtures
If Me.Dirty = True Then Me.Dirty = False
Me.HomeFixtures = Frm!TextPriceTotal
Set frm=Nothing
End Sub
 

PatAccess

Registered User.
Local time
Today, 03:15
Joined
May 24, 2017
Messages
284
OK! Guys, my VBA professor responded and gave me the Fix:
He had me pass the WindowMode argument equal to acWindowMode acHidden
It opens the form but I don't see it and I close it before the Exit Sub. That was the only fix for this code to work.

Thank you very much for all the help
 

PatAccess

Registered User.
Local time
Today, 03:15
Joined
May 24, 2017
Messages
284
I am confused with the Forms!Frm_HomeFixtures and field [HomeFixtures].

Fields are in tables, controls are on forms.
Forms are in the front end, they can be populated with data from the backend (table(s).

The 2450 seems to indicate an attempt to use info on a form that is not open or doesn't exist.

Please tell us more or post a couple of jpgs to clarify your requirement and set up.
What are you trying to do in plain English?

The TextPriceTotal is a control on a form. It is an unbout text field that calculates values
Thank you for the help!
 

Minty

AWF VIP
Local time
Today, 08:15
Joined
Jul 26, 2013
Messages
10,371
At the risk of repeating myself, and to get you to the proper solution to this, how are you setting the value of that unbound control on that form?

It must by definition be a query or a Sum() of controls on that form , or possibly a DLookUp(). Therefore you can almost certainly recreate that in your other form. Then you wouldn't need to open and close the form to get you to the same result.

Does that make sense?
 

PatAccess

Registered User.
Local time
Today, 03:15
Joined
May 24, 2017
Messages
284
At the risk of repeating myself, and to get you to the proper solution to this, how are you setting the value of that unbound control on that form?

It must by definition be a query or a Sum() of controls on that form , or possibly a DLookUp(). Therefore you can almost certainly recreate that in your other form. Then you wouldn't need to open and close the form to get you to the same result.

Does that make sense?

It is a Sum() of controls on that form
So do you mean, create another unbound field and make it equal to the previous one?
 

MarkK

bit cruncher
Local time
Today, 00:15
Joined
Mar 17, 2004
Messages
8,181
You can open it for a while then immediately closed it when you got what you want. Otherwise some spikepl will catch us for our inefficient code:

Private Sub Form_Load()
Dim frm as form
Set frm=Form_Frm_HomeFixtures
If Me.Dirty = True Then Me.Dirty = False
Me.HomeFixtures = Frm!TextPriceTotal
Set frm=Nothing
End Sub
I do not recommend this solution. At this line...
Code:
Set frm=Form_Frm_HomeFixtures
...a hidden instance (non-default instance) of the form is opened. This may work, but it is a sloppy way of solving the problem. If you need a result that will be consumed by multiple forms, I suggest writing a public VBA procedure in a standard module that performs the data access and calculations necessary to produce that result. Then, program both forms to call that public procedure. Opening an existing form to grab a result from a single control on that form is a messy beginners hack, and is worth avoiding.
hth
Mark
 

Minty

AWF VIP
Local time
Today, 08:15
Joined
Jul 26, 2013
Messages
10,371
If the controls on that form with the Sum() on, are based on a specific record, and the second form you are opening that needs the value from that form, I'm puzzled by the process flow from the original form, to the one you need the value on (I'll call it Form B).

Why not open Form B from Frm_HomeFixtures, simply hide Frm_HomeFixtures, whilst Form B is open?

Have I misunderstood the process flow?
 

PatAccess

Registered User.
Local time
Today, 03:15
Joined
May 24, 2017
Messages
284
So I have Form A, Form B, Form C
I open Form B from Form A and 4 values carry over.
1 value from Form C also carries into form B
the value from Form C is an unbound text field I've created that has a Sum() expression that calculates several vales within that From C.

But when I opened Form B from Form A, it was giving me error code 2450 because it also wanted Form C to be opened to grab that value but I did not want to see From C opened
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:15
Joined
May 7, 2009
Messages
19,233
Hello what is non-default. Every instsnce is a deault. Its a form Class.
 

MarkK

bit cruncher
Local time
Today, 00:15
Joined
Mar 17, 2004
Messages
8,181
You can google or search this forum for more info on non-default instances if you so choose. For someone with your skills, I think it would be worthwhile for you to understand how and when to use them, and how and when not to. Or you can make the incorrect statement on here that "every instance is default." It is totally up to you.
hth
Mark
 

Minty

AWF VIP
Local time
Today, 08:15
Joined
Jul 26, 2013
Messages
10,371
So I have Form A, Form B, Form C
I open Form B from Form A and 4 values carry over.
1 value from Form C also carries into form B
the value from Form C is an unbound text field I've created that has a Sum() expression that calculates several vales within that From C.

But when I opened Form B from Form A, it was giving me error code 2450 because it also wanted Form C to be opened to grab that value but I did not want to see From C opened

So is there anyway you could get those values in Form A and Form C without having the forms actually open?
They sound as is they are simply gathering various bits of data, and you could easily do that as Markk suggested in a module and simply return the values you need.

Could you screen shot the three forms and indicate which one is opened from the other?
It sounds as if this could all be achieved on one form with some Tab Pages to be honest.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:15
Joined
May 7, 2009
Messages
19,233
No need to google i have my books. Written by real mvp's.
 

Users who are viewing this thread

Top Bottom