Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2008

Tip: Looking for answers? Try searching our database.

Setfocus in a field on a subform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave - 13 Mar 2008 19:54 GMT
I thought I had asked this before but can not find my post.

when I open a form that contains a subform I want focus to be on a fields on
the subform.

this is what I have tried:

On the open event of the sub

       me.subName!FieldName.setfocus

       works if I ONLY open the subform - but does not work if I open the
main form

on the open even of the Main form

   me.frmMain!subName!FieldName.setfocus
   me.subName!FieldName.setfocus
   me.FieldName.setfocus

None of them work

What am I doing wrong

Thanks

dave
Jeanette Cunningham - 13 Mar 2008 20:09 GMT
Dave,
you need the correct syntax to refer to the subform
Often it is best done in 2 steps, first set focus to the subform control,
then to the control you want.

   Me.SubformControlName.SetFocus
   Me.SubformControlName.Form.ControlName.SetFocus

note that the SubformControl is separate from the subform that is inside it.
The SubformControl often has a different name from the subform.

Jeanette Cunningham

>I thought I had asked this before but can not find my post.
>
[quoted text clipped - 23 lines]
>
> dave
Dave - 13 Mar 2008 20:24 GMT
I follow the 2 steps process and it makes sense
However not sure I follow/understand "subformControl"
How would I know/find the name to that if it is not the subform name

Thanks for the reply

dave

> Dave,
> you need the correct syntax to refer to the subform
[quoted text clipped - 37 lines]
>>
>> dave
Jeanette Cunningham - 14 Mar 2008 00:47 GMT
Dave,
open the parent form in design view.
Click only once on the subform - you should see black handles around the
edge of it - the same as if you clicked a textbox, combo, image control etc.
Then click on it again, the black handles disappear.

The black handles are on the edge of the subform control.
The second click takes you into the subform itself.

Click on the main form then click once on the subform control and see the
black handles.
Look on the Other tab and find the name of the subform control.
It might be called Child followed by a number, or it may have a different
name.
Have a look on the property dialog on the Data tab, you should see Source
Object at the top of the list.
The Source Object gives you the name of the form that is currently in the
subform control.

You can swap different subforms into the same subform control ( more
advanced stuff)

Jeanette Cunningham

>I follow the 2 steps process and it makes sense
> However not sure I follow/understand "subformControl"
[quoted text clipped - 45 lines]
>>>
>>> dave
Dave - 18 Mar 2008 01:34 GMT
Thanks - finally got it working.
Had a field on the main form that was grabbing all the attention :)

dave

> Dave,
> open the parent form in design view.
[quoted text clipped - 70 lines]
>>>>
>>>> dave
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.