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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing data from a subform to its parent form 6

Status
Not open for further replies.

eatwork

Technical User
May 16, 2005
155
CA
Hi I was wondering if anyone has experience with passing subform data to a field in the parent form. I have a form that collects totals from a subform while the user enters its data. I can access or read the data by using Forms!frm_payroll2!payrollTotalRHours . I tried to set the field by using Set Forms!frm_payroll2!payrollTotalRHours = empTotHrsR but it gave me an error. Any help would be appreciated. Thank you very much
 
Just en example that might help you along:
dim Frm As Form
Set Frm = Forms!YrMainForm!YrMainFormSub.Form
Forms!YrMainForm!YrFld= Frm.RecordsetClone.RecordCount


Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
What about replacing this:
Set Forms!frm_payroll2!payrollTotalRHours = empTotHrsR
By this ?
Forms!frm_payroll2!payrollTotalRHours = Me!empTotHrsR

but it gave me an error
any chance you could post the whole error message ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Your: Forms!frm_payroll2!payrollTotalRHours = Me!empTotHrsR
should work.
What is the err msg and on what event is this code placed?

Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
HI thank you for your responses. The error message is "Run time error '424': Object required" Thanks
 
Looks like Access can not find either the form or the field
spelling error ?

Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
It could be a reference error to. I found that I have to add a form_ when referencing fields on different forms. I think that this is the case if you are not defining your forms in a Set method. I have not tested my theory but that might be the case.
 
You can also use any of the following 3 lines of code, replace the names accordingly. This code passes a value stored in the sub form field PhoneNumber to the Master form field named txtTest, the Master form is named frmMaster, the sub form is named frmSub.

Forms!frmMaster!txtTest = Forms!frmMaster!frmSub.Form!PhoneNumber

OR

Forms!frmMaster!txtTest = Me!PhoneNumber

OR

Forms!frmMaster!txtTest = Me.PhoneNumber
 
How are ya eatwork . . . . .
eatwork said:
[blue] . . . passing subform data to a field in the [purple]parent form.[/purple][/blue]
SubForms can be three levels deep:

[tt][blue]MainForm with subForm [purple]Level1[/purple]
Level1 subform with subform [purple]Level2[/purple]
Level2 subform with subform [purple]Level3[/purple][/blue][/tt]

By any chance is the [purple]Parent Form[/purple] a subform as well ([purple]Level 1 or 2[/purple])?

This would explain why [blue]form references in this thread[/blue] that should work, are failing . . .



Calvin.gif
See Ya! . . . . . .
 
HI everybody, thank you for your suggestions. I have managed to find the problem. The problem was that I was resetting the parent forms recordsource with a distinct keyword and it wouldn't allow me to update the current record. Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top