RunTime error 2450 Object required

  • Thread starter Thread starter LanWanMan
  • Start date Start date
L

LanWanMan

Hello All.

I have a subform which has a combo box which, "After Update" opens a popup
form bound to a different table. When it does, it is supposed to pass two
values into the popup form. Access can't fint the form frmEmployeeAssign.

Forms!frmAddEmployee!EmpInvLast = Forms!frmEmployeeAssign!EmpLast
Forms!frmAddEmployee!EmpInvFirst = Forms!frmEmployeeAssign!EmpFir

I tried using subforms! but that causes a different error. Ideally, I would
also like the "on close" event of the popup form to pass a value back to the
subform.

If you can help, please post to the group.

Thanks,

Michael
 
Hello All.

I have a subform which has a combo box which, "After Update" opens a popup
form bound to a different table. When it does, it is supposed to pass two
values into the popup form. Access can't fint the form frmEmployeeAssign.

Forms!frmAddEmployee!EmpInvLast = Forms!frmEmployeeAssign!EmpLast
Forms!frmAddEmployee!EmpInvFirst = Forms!frmEmployeeAssign!EmpFir

I tried using subforms! but that causes a different error. Ideally, I would
also like the "on close" event of the popup form to pass a value back to the
subform.

The syntax for a subform is a bit peculiar. If frmEmployeeAssign is
being used as a Subform, you need to reference the name of the
mainform upon which it is a subform, and the Name property of the
Subform Control (which may or may not be the same as the name of the
form within that control):

= Forms!frmEmployeeMainForm!frmEmployeeAssign.Form!EmpLast

Or since the code is actually running on the subform, just use the Me!
shortcut which means "this form":

= Me!EmpLast


John W. Vinson[MVP]
 
John,

Thanks for your reply. I am not certain what you mean by the "name
property". I reworked the code to read:

Forms!frmAddEmployee!EmpInvLast =
Forms!frmclaims!frmEmployeeAssign.Form!EmpLast

But now I get error 2465, cannot find the field "frmEmployeeAssign. I think
I am almost there if you can help just a bit more.

frmClaims is the main form and frmEmployeeAssign is the subform.
frmAddEmployee is the popup form intended to receive the value.

Thanks,

Michael
 
John,

Thanks for your reply. I am not certain what you mean by the "name
property". I reworked the code to read:

Forms!frmAddEmployee!EmpInvLast =
Forms!frmclaims!frmEmployeeAssign.Form!EmpLast

But now I get error 2465, cannot find the field "frmEmployeeAssign. I think
I am almost there if you can help just a bit more.

frmClaims is the main form and frmEmployeeAssign is the subform.
frmAddEmployee is the popup form intended to receive the value.

The Subform Control is the white "box" control on the mainform, in
which the Subform is displayed. The form within that box has a Name
property; but so does the box, the Subform Control itself. It is the
latter, the name of the subform control, which is needed in the
syntax.

Try opening the form in design view. Click the *edge* of the subform
so it highlights (black handles on the middle of each side). View its
Properties, particularly the Name property. This is what you need to
use in place of frmEmployeeAssign.

Or, as suggested, simplify this to

Forms!frmAddEmployee!EmpInvLast = Me!EmpLast

John W. Vinson[MVP]
 
John,

Sorry to keep bugging you, but I greatly appreciate your help. I have lost
20,000 brain cells over this one issue. Again, thanks for your help.

I did what you said. I opened the main form, selected the entire subform
window and viewed the properties. In the "Other" tab, the "Name" was
tblEmployeeAssignsubform. I reworked the code to read:

Forms!frmAddEmployee!EmpInvLast =
Forms!tblEmployeeAssignsubform!EmpLast
Forms!frmAddEmployee!EmpInvFirst =
Forms!tblEmployeeAssignsubform!EmpFirst

I still get the 2450, can find the form "tblEmployeeAssignsubform". I tried
Me!EmpLast and I get a 2465, can't find the field "EmpLast". This subform
was created from within the main form using the wizard. Maybe that makes a
difference.

Thanks again,

Michael
 
John,

Sorry to keep bugging you, but I greatly appreciate your help. I have lost
20,000 brain cells over this one issue. Again, thanks for your help.

I did what you said. I opened the main form, selected the entire subform
window and viewed the properties. In the "Other" tab, the "Name" was
tblEmployeeAssignsubform. I reworked the code to read:

Forms!frmAddEmployee!EmpInvLast =
Forms!tblEmployeeAssignsubform!EmpLast
Forms!frmAddEmployee!EmpInvFirst =
Forms!tblEmployeeAssignsubform!EmpFirst

The correct syntax is

Forms!frmAddEmployee!EmpInvLast =
Forms!frmAddEmployee!tblEmployeeAssignsubform.Form!EmpLast
Forms!frmAddEmployee!EmpInvFirst =
Forms!frmAddEmployee!tblEmployeeAssignsubform.Form!EmpFirst

I still get the 2450, can find the form "tblEmployeeAssignsubform". I tried
Me!EmpLast and I get a 2465, can't find the field "EmpLast". This subform
was created from within the main form using the wizard. Maybe that makes a
difference.

Is there a Control - a textbox - on the Subform with a Name property
EmpLast? Or does the control bound to the Emplast field have some
other name?

One other question, that I should have asked earlier: WHY are you
doing this? It appears that you're storing these names redundantly.
Generally this is a Bad Idea; you'ld store the name, once, in the
Employee table, and then just store the employee ID in related tables,
say using the Master/Child Link Field of the subform, and use a query
to look up the name. Do you really WANT to be doing this?

John W. Vinson[MVP]
 
John,

Thanks again. I know nobody is obligated to reply to the posts, so I
appreciate it. I try and do my duty of answering questions in other groups
that I can.

You are right, I am probably over-complicating things. Here is the jist of
it:

I have 3 tables:

tblClaims
ClaimID (key)
etc... (Details of the claim)
tblEmployeeAssign
EmployeeAssignID (key)
EmpLast (ComboBox querying a static table)
EmpFirst
ClaimID
EmployeeID
tblEmployeeInvolve
EmployeeID (key)
EmpInvLast
EmpInvFirst
etc... (Details of the employee)

I created tblEmployeeAssign to link the claims and employees. A single
claim can have many employees involved. tblEmployee contains the details of
the employee such as injuries, etc. I added the EmpLast and EmpFirst to
tblEmployeeAssign to use a combo box for the end user to select an employee.
Then I created frmEmployeeAssign subform using the wizard in the frmClaims.

Originally, tblEmployeeAssign had only EmployeeAssignID, ClaimID and
EmployeeID and I used a command button to open frmEmployeeInvolve, but I
could not figure how to create the new record in tblEmployeeAssign with the
ClaimID and EmployeeID.

Ideally, I would like to have a continuous subform on the main form with an
"Add" button for employees, and the list grows as employees are added, but I
need the frmEmployeeInvolve to be a popup because there is not enough room
on the original form.

I will go back to the basics and redesign without the redundant fields and
then maybe my questions will not be so ambiguous.

Again, thanks for your help.

Michael
 
John,

Thanks again for your help. I went back to the basics and removed the
duplicate fields and used the subform wizard and I have it working like a
charm.

Thanks again,

Michael
 
Back
Top