Hi everyone
I have a main form with two subforms and one of the subforms has a further subform. Lets call them Main, Sub1, Sub2 and Sub1Sub.
I have the following code which triggers as soon as I open Main:
Private Sub Form_Current()
Sub1.SetFocus
On Error Resume Next
DoCmd.GoToRecord , , acLast
On Error GoTo 0
Forms!Main!txtBox1.SetFocus
the code contines .....
It works, in that the final record on the first subform is displayed and focus returns to the main form. I'd like to have focus move to a textbox on Sub1Sub, but when I change the final line to Forms!Sub1Sub!txtBox2.SetFocus, it generates an error "... can't find the form <Sub1Sub> referred to ... I use exactly the same name of the subform as displayed in the database window.
If I change the final line to Sub1Sub.SetFocus, or Sub1Sub!txtBox2.SetFocus, it generates an error "Object required".
I'm surprised that I can't set the focus on the second subform (Sub1Sub). Can someone tell me how I can set the focus where I want it to be? I hope I've explained the situation sufficiently.
Thank you.
I have a main form with two subforms and one of the subforms has a further subform. Lets call them Main, Sub1, Sub2 and Sub1Sub.
I have the following code which triggers as soon as I open Main:
Private Sub Form_Current()
Sub1.SetFocus
On Error Resume Next
DoCmd.GoToRecord , , acLast
On Error GoTo 0
Forms!Main!txtBox1.SetFocus
the code contines .....
It works, in that the final record on the first subform is displayed and focus returns to the main form. I'd like to have focus move to a textbox on Sub1Sub, but when I change the final line to Forms!Sub1Sub!txtBox2.SetFocus, it generates an error "... can't find the form <Sub1Sub> referred to ... I use exactly the same name of the subform as displayed in the database window.
If I change the final line to Sub1Sub.SetFocus, or Sub1Sub!txtBox2.SetFocus, it generates an error "Object required".
I'm surprised that I can't set the focus on the second subform (Sub1Sub). Can someone tell me how I can set the focus where I want it to be? I hope I've explained the situation sufficiently.
Thank you.