New record in sub form - to specific field (1 Viewer)

stu_c

Registered User.
Local time
Today, 15:34
Joined
Sep 20, 2007
Messages
489
Hi all
I have a form with a sub form, when I click the new record button on the main form I want it to start in a specific field on the sub form (StartDate), I have tried doing tabs which didn't work and also tried the below but stick the field has not been selected, any suggestions

Code:
Private Sub BtnNewRecord_Click(()
StartDate.SetFocus
 

bob fitz

AWF VIP
Local time
Today, 15:34
Joined
May 23, 2011
Messages
4,717
Try
Code:
Private Sub BtnNewRecord_Click(()
Me.[NameOfSubFormControl].[Form].StartDate.SetFocus
 

cheekybuddha

AWF VIP
Local time
Today, 15:34
Joined
Jul 21, 2014
Messages
2,238
Hi,

There are two parts to a subform:
- the subform container control
- the actual form used as the subform itself

Depending on how you added the subform to your mainform, these may or may not be named the same.

To reference a control on a subform you need to do so via its container control, and its .Form property.

So your code will look like:
Code:
Me.subformControlName.Form.StartDate.SetFocus

Edit: ninja'd! 👍
 
Last edited by a moderator:

Users who are viewing this thread

Top Bottom