Set focus to sub form

Gavx

Registered User.
Local time
Tomorrow, 03:59
Joined
Mar 8, 2014
Messages
155
On a main form I have 2 sub forms.
On the main form I have a command button that asks how many guests in a booking and depending on the response populates the subform with Guest Names. However it will only do this if I click on the subform and then click the command button.

I want to include some code that sits behind the command button on the main form that will duplicate the otherwise manual selecting of the sub form. And I am thinking this is a SetFocus procedure.

I have tried this code;
[Forms]![Booking].[SubForm1].SetFocus
where Booking is the name of the form. I do not know whether the Subform is #1

but it doesn't work. .

How do I fix this please.
Gavin
 
... populates the subform with Guest Names.
From where should the names come from, manual input or ...?
... I do not know whether the Subform is #1
We either, so open the main form in design view select the sub-form and find out the name of the sub-form.
Instead of:
[Forms]![Booking]![YourSubFormName].SetFocus
it is better to use
Me.[YourSubFormName].SetFocus
 
That worked.
thanks
 

Users who are viewing this thread

Back
Top Bottom