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

subform data

Status
Not open for further replies.

techkenny1

Technical User
Jan 23, 2009
182
AU
Hi all,
I have two subforms on a mainform. Is it possible to be able to use a text box from one subform to the other subform.

For example I can use this code, "=Form128_Monday.Form!T0500" for as text box on the mainform, but how can I reference a text box on another subform..

Many thanks,

kp
 
Assume these names
frmMain
with two subform cotrols
subFrmCtlOne
subFrmCtlTwo

to reference "txtBxOne" in the form contained in subFrmCtlTwo from the form module contained in subFrmCtlOne

me.Parent.subFrmCtlTwo.Form.txtBxOne
 
Hi RuralGuy,
Many thanks for your link. Quite useful.
However I'm just not sure how to use this to be able to reference a text box on one subform to another subform. if you could point me in the right direction, that would be good.

many thanks,

kp
 
MajP supplied the correct answer to your last question. You could also reference using the Forms collection.
Forms!MainFormName!SubFormControlName.FORM!ControlName

(RG for short) aka Allan Bunch MS Access MVP acXP ac07 winXP Pro
Please respond to this forum so all may benefit
 
techkenny1,
MajP took the time to offer up some sample names of forms, subforms, and controls while you haven't done the same. The link provided by RuralGuy has the same.

If you can't understand the syntax the least you should do is provide your names.

One hint, MajP's use of "Me." isn't appropriate outside of a module. Use the expressions under Not in these forms.

Duane
Hook'D on Access
MS Access MVP
 
Hi all,
Thanks for all your replies. While still a novice at this database stuff,I do try what has been given to me to try.

In this situation, I have a main form on which I have 2 Subforms, Subform1 and Subform 2.

I have a text box on subform 1 (Dayrate).
On Subform 2 I have put a text box with these properties,Name = DayRateA
and using the code provided in the link;Forms!Form127!Subform1.Form!Subform2.Form!Dayrate,on the Control Source.

According to the 'Not in these forms' that that should work, however it only shows an error. So where is this error? I have tried various variations of that link but to no avail.

many thanks,

kp





 
First off, every expression in the Control Source of a text box must either be a field name or begin with an equal sign. The use of the term "code" is generally reserved for statements in a module. Another important consideration is the "name" of a subform control or text box is not always the same as the Source Object and Control Source. Quite often these are the same but with this question, the "name" property is the most significant.

Assuming you have:
main form named: Form127
with two subform controls named: subform1, subform2
On the subform in the control subform2 you have a text box named: DayRateA
You want to reference the value of this text box in a text box in subform1. The control source would be:
=Forms!Form127!subform2.Form!DayRateA

BTW: do yourself a favor and find and use a naming convention that doesn't allow names like subform1 etc.

Duane
Hook'D on Access
MS Access MVP
 
Hi dhookom,
Many thanks for your comments. I have Changed the forms to run concurrent in the Db. So the first form is Form100
and the second is form101
So on the mainform I now have 2 forms, form100 & form101.
I used your formula on the text box as you have indicated.

When the = sign is enterd into the control source I get the error ' expression contains invaild syntax' You may have entered an operand without an operator.

I'm just not sure now what this is. This is what I have entered into the control source as below.
=Forms!Form127!Form100.Form!DayRateA

Many thanks,

kp
 
Why not using the expression builder ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
techkenny1,
I agree with PH regarding the expression builder.

I don't understand why you give your objects numbers and not descriptive titles like "sfrmProjectTasks" or "sfrmEmpWorkHrs". It also isn't clear from any of your replies that you understand the difference between the name of your subform and the name of the subform control as seen on your main report.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top