Full Version: SetFocus on nested Subform
UtterAccess Forums > Microsoft® Access > Access Forms
ecurns
Hello,
I'm trying to set focus on a nested subform and can't figure out the correct syntax.
MainForm: fmCashReceivedform
Subform1 nested in MainForm: frmCashReceivedSub
Nested form in Subform 1: frmBenandItem
I have a control txtCheckNumber on frmCashReceivedSub, on the lost focus event I'm trying to set the focus to "txtItemization" field on frmBenandItem
I've tried it a couple different ways but none of them work. It reads the code, no errors but doesn't set the focus to the field.
This code is erroring out saying it doesn't know what frmcashreceviedsub is.
[code]
Me![frmcashreceviedsub].Form!frmBenandItem.Form!txtItemization.SetFocus
freakazeud
Hi,
I think it would just be:
e!frmBenandItem.Form!txtItemization.SetFocus
HTH
Good luck
niesz
See if this helps you out. There's an attachment on the original post.

You may also want to double check the spelling of your subformCONTROL object.
ecurns
This one Me!frmBenandItem.Form!txtItemization.SetFocus
doesn't error out but it doesn't select the control on the subform (it's moving along the tab order so it goes to the command button on the form)
did double check the spelling (I copied and pasted it just in case there was an error I didn't see) but that didn't fix the problem.
I'll read the post Walter is referring to and see if it shines some light on this.
Erica
MattJ
To set focus to a control on a subfomr you must first set the focus to the sub-form control itself, then the control on the subform... So, try:
Me!frmBenandItem.SetFocus
Me!frmBenandItem.Form!txtItemization.SetFocus
HTH
Matt
ecurns
Thanks Matt!! That worked perfectly.
MattJ
Glad we could help!
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.