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!

Updating fields in Form b with fields from Form A

Status
Not open for further replies.

achillese

Technical User
Jun 26, 2005
25
AU
I need some help on this...

I have Form B sitting inside From A. Form B is not really a subform of A, they are not linked.

In Form A, I have a text field (not save in database) called PERIOD.

In Form B, I have several fields called by a query, a field in Form B called PAID_PERIOD will be updated by PERIOD field in Form A when you check the UPDATE field in FORM B. Note, the UPDATE field in FORM B is logical (a yes or no field). I tried to put a code in the ON CLICK property of the UPDATE field and it did not work.

I don't know if the the following code is correct:

Private Sub UPDATE_Click()

[FORM_A].[Form]![PAID_PERIOD] = [FORM_B].[Form]![PERIOD]
Me.FORM_B.Requery

End Sub


THANKS +++
 
Even if form B is not linked it still is a subform. It sits inside a subform control. The code is triggered in a event from form B.
What about:
Code:
forms![A]![Paid_Period] = me![Period]
me.requery
In order to reference Form A you have to go to the forms collection. Also this assumes Paid_Period and Period are fields not controls.

 
The link PHV shows is a good resource for referencing controls on subforms. It sounds like you are doing the reverse, and need reference controls or fields on the main form from an event on the sub. Use the "parent" property to do this. The "parent" property of a subform is the mainform. So you can generalize the above
Code:
me.parent.Paid_Period = me.Period
or with bang
me.parent![Paid_Period] = Me![Period]
This will throw an error if the subform is used as a stand alone form.
 
Thank guys for all your answers. Yes, Form_B should take from Form_A not the other way around.

I figure out already with your help...my problem also is syntax.

However, how do you make form fields referencing if Form C sits in TAB FORM B and TAB FORM B sits in Form A. I want to update a field in Form C from field in Form A. Also, I want to Requery Form C in the After Update field in Form A.

Thanks +++
 
It does not matter that it is on a tab control, treat it as it was not. I do not understand why that is, but that is how it works. Using dot and "" notation.

Me.subFrmCntrl.Form.Controls("control name")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top