Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Error

Status
Not open for further replies.

tiger3p

IS-IT--Management
Oct 29, 2003
32
US
Hello all,

Was hoping someone could help me with an error in my form. I tried copying a form with a subform and modifying it with another subform. I'm getting the following error:

Run-time error '424':

Object required

When I click on the debug, it shows the following highlighted in yellow:

If Form_fmrEEInfo.Text2.Value > 0 Then

Any idea why I'm getting this error?
 
Hmm I have no idea about that.. I can paste the code here if that would help.
 
You are most likely getting the error because "Form_fmrEEInfo.Text2.Value " does not exist. In all your copying and adding subforms, go back and make sure the form name was retained and is spelled the same as your code. Also not sure what objects you are referencing here, but maybe Form_fmrEEInfo.Text2.Value should be Me.Text2.Value, or if you reference from another form, forms!Form_fmrEEInfo.Text2.Value ?

Computers make very fast, very accurate mistakes.
 
You probably need to post some code. What PHV is suggesting there are rules to referring to a control on a subform. Normally you have a main form, a subform control, a subform within the subform control, and then controls on the subform. To reference a control on a sub

forms("name of main form").nameSubFormControl.form.nameControlOnSubform

often the subform control and the subform have the same name by default
 
You won't be able to access the subforms controls and properties directly by using the form's design name; you have to access them thru the Subform class's Form property, like so:

Code:
Sub GetSubFormData
rem Parent form has a subform named Child1
rem Child1's Form has an edit control named SomeCtrl
  Me.Child1.Form.SomeCtrl.Value = "Hello"
end sub

The subform's name on the parent form is NOT the same as the name you gave it when designing it; it is the name you gave it when you put it on the parent form. Default name would be something like Child1.
 
I'm going to say that the problem is this:

Form_fmrEEInfo is probably not your form name. Your form name is probably:

fmrEEInfo (or is it misspelled and should be frmEEInfo?)

and you are referring to it using what it looks like in the VBA browser window. the Form_ part of it is not the name, but an internal thing with Access.


Bob Larson
A2K,A2K3,A2K7,SQL Server 2000/2005,Crystal Reports 10/XI,VB6, WinXP, and Vista
Free Quick Tutorials and Samples:
 
Prataratt,
You are incorrect in your statement
The subform's name on the parent form is NOT the same as the name you gave it when designing it; it is the name you gave it when you put it on the parent form. Default name would be something like Child1.
The name of the subform is in fact the name you gave it. If you wrote
me.yoursubformcontrolName.form.name
it would return the name of the subform object within the subform control. This would be the name of the subform that you designed. "Child1" as you refer to is the name of the subform control not the name of the form within the subform control. The thing that you drop on a form is a subform control not a form object.
 
Prataratt and boblarson,
These are kind of subtle points dealing with object oriented programming, but there are two other statements that are not true.
Code:
 You won't be able to access the subforms controls and properties directly by using the form's design name
You most definitely can. You can not use the Forms collection as most people do to return a form object but you can use the form object class directly

Form_fmrEEInfo.Form.Text2.Value

This returns the form of the Form_frmEEinfo object. You can use this notation to return properties of a form that is not even open. Try it.

the Form_ part of it is not the name, but an internal thing with Access.
Well actually this is the name of the form object. You can use the name property index to return an instance of this object but the object itself is named Form_fmrEEinfo

For example if I wanted to have multiple instance of this form I could do

dim frm2 as new Form_fmrEEinfo
but not
dim frm2 as new fmrEEinfo


Your discussion aboutThis may be adding more confusion
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top