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

Linking Field on SubForm to Field on Main/ParentForm?

Status
Not open for further replies.

Buckar00B0nzai

Technical User
Jun 17, 2009
50
0
0
US
I have a Form (Form.Main) with a subform (Form.Sub) embedded in it. Here's what I would like to do.

If I update a field (Status) on the subform, can I force it to update a field on the main form with an IF statement? I'm thinking:

Private Sub Status_AfterUpdate()
If Me.Status.Value = "Blue" Then
Me.NEED HELP HERE.Value = Now()
Else
End If
End Sub

Am I even close?

Thank you for your help.

Buckaroo Banzai
 
As a starting point, replace this:
Me.NEED HELP HERE.Value = Now()
with something like this:
Me.Parent.Form![name of control].Value = Now()

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I do not like to do this in my suforms, because I like to reuse subforms. So instead I trap the event in the main form without any code in the subform. Basically the main form listens for a subform event to occur.

Private WithEvents subFrmControl As Access.TextBox

Private Sub Form_Load()
Set subFrmControl = Me.SubFormName.Form.ControlName
subFrmControl.AfterUpdate = "[EventProcedure]"
End Sub

Private Sub subFrmControl_AfterUpdate()
'Capture the subform event here
MsgBox "SubFormChanged"
End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top