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

Referencing Subform Fields

Status
Not open for further replies.

ottograham

Technical User
Mar 30, 2001
109
US
I have a form with two subforms on it. I would like to program a button on the main form that moves to the Comments field in Subform2. I've tried subform2!Comments.setfocus which doesn't work, and I can't find the answer in the Help screens.

I'm sure this is an easy one for all.

Thank you
 
Otto:

I think what you need would look like this:

Forms!frmMain!frmSubForm2!Comments.SetFocus
Larry De Laruelle
larry1de@yahoo.com

 
Larry:

Thanks for the response. I tried it and continue to get

Run time error2465. MSAccess can't find the field "qtransaction" referred to in your expression.

Qtransaction is the subform name, but I had changed it to subTransForm in the Properties section under "Name". I used both the original form name and the new name.
Form: qQuoting
SubForm: qTransaction
Field: TransComments

The code was forms!qquoting!qTransaction!TransComments.setfocus

What am I doing wrong. Thanks for your help.
 
I usually use the following syntax:

Forms!qquoting!qTransaction.Form!TransComments.SetFocus
 
Larry & Ninfan:

Thanks to both. I omitted first setting the focus to the subform, after which I used the docmd transcomments.moveto approach which worked.

Thanks again for your help.

Private Sub Trans_Xdate_Click()

Dim ctl As Control
Set ctl = Forms!qquoting!subTransaction!TransComments

subTransaction!TransDescription = "Xdate"
Forms!qquoting!subTransaction.SetFocus

DoCmd.GoToControl ctl.Name

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top