Referring to form control from subform

K

Kurt

I have a main form (frmMain) with a subform (fsubTest).
The main form has an unbound text box (txtQ) in the Form
Header. When I enter a combo box control (Field1) on the
subform, I would like the status bar text of Field1 to
appear in txtQ, the main form's unbound text box.

I've been able to do this when a subform is not involved.
For example, if Field1 is on the main form instead of a
subform, this works:

Private Sub Field1_GotFocus()
Me.txtQ = Me.Field1.StatusBarText
End Sub

However, since Field1 is on a subform, I'm having trouble
referring to txtQ, the control on the main form. Here's
what I tried:

Private Sub Field1_GotFocus()
Me.frmMain!txtQ = Me!Field1.StatusBarText
End Sub

This give me a "Compile Error: Method or data member not
found."

I've reviewed the issue at the following link but to no
avail: http://www.mvps.org/access/forms/frm0031.htm

Thanks.

Kurt
 
G

Gary Miller

Kurt,

Try...

Private Sub Field1_GotFocus()
Me.Parent!txtQ = Me!Field1.StatusBarText
End Sub

Gary Miller
 
K

Kurt

Than you Gary. This worked perfectly. Now an inverse
problem:

I'm on the main form (frmMain) and need to refer to the
subform (fsubTest). More specifically: When the user
updates the answer to FieldABC on the main form, I'd like
the focus to jump to the first control (FieldXYZ) on the
subform. I tried the following code but nothing happens
when the answer for FieldABC is updated.

Private Sub FieldABC_AfterUpdate()
Me!fsubTest.Form!FieldXYZ.SetFocus
End Sub

Thank you. - Kurt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top