changing focus from control on one subform to control on another subform

ehdoh

Registered User.
Local time
Yesterday, 23:08
Joined
Jun 24, 2003
Messages
58
I have a main form (TABS-2) that resides on the first tab of a tab control. I have four subforms linked to the main form (through the link child/master fields), each residing on a separate tab of the tab control. The subforms are named R4toR6form, R7toR9form, R10toR12form, R13toR15form. I created the subforms first as independent forms and then by dragging and dropping them onto the tabs to make them act as subforms.

I need to have the last field on the main form set up so that when the tab key is depressed, the focus is set to the first field on the first subform. I have accomplished this with the following code (compliments of JKpeus):

Private Sub fieldname_KeyDown(KeyCode as Integer)
If KeyCode = 9 Then
Me.R4toR6form.SetFocus
End If
End Sub

I have been trying to apply this same program to the last field on R4toR6form to move the focus to R7toR9form. And I need to do the same with the subsequent subforms. I've tried this through On Key Down and through On Lost Focus and each time I get the message "method or data member not found." The debugger highlights the subform name, which tells me that while the main form recognized the first subform, the subforms do not recognize each other.

Does anyone know of a way to accomplish what I am trying to accomplish? I am setting this up for an enormous questionnaire, and it is important that I minimize mouse usage for those who will be entering the data--hence my desire to be able to use the tab key to move from the last field on one subform to the first field on the next subform.

Thanks for your help!!
E.
 
I think I solved the problem I was posting about. I will put the code in here for you all to see:

Private Sub Combo95_LostFocus()
[Forms]![TABS2].[R13toR15Form].SetFocus
End Sub

(NOTE: I changed the name of the mainform from TABS-2 to TABS2 -- the dash was giving me problems in VB).

My question now is ... will referencing the mainform when setting focus from one subform to the next subform give me any problems? Using this code seems to have solved my problem of needing to set the focus from one subform to another, but I don't want to run into any surprises with this down the road.

Cheers,
E. :rolleyes:
 

Users who are viewing this thread

Back
Top Bottom