if-then statement to jump to subform on exit from control

ehdoh

Registered User.
Local time
Today, 07:37
Joined
Jun 24, 2003
Messages
58
I have a main form with several subforms embedded in it. At points in the mainform and several points in the subforms, the answers provided in combo boxes will determine where the user should be directed for the next portion of data entry. Thus far I have used macros to govern this. When an entry on the mainform requires a jump to a subform, I tried governing this via an openform command on a macro but the problem is that the subform then opens as its own form. What I want to occur instead is for the user to be directed to the first control in the subform (where it is embedded in the mainform) rather than have the subform open anew.

Is there a way to do this via code? I imagine I would be able to control this movement more readily in code than in a macro, hence me posting this question on this particular forum. If there is a way to do this via macro and any of you know how, I would also be interested in learning this.
 
Yes, you can control all movements via code. You can use the On Exit, Lost Focus, After Update, or Click events (among others) for controls to govern where the cursor should go next, based on what's come before.

For example, if you wanted to move the cursor to a subform only if the user selected a checkbox, here's some sample code:
Code:
Private Sub chkNew_Click()
    If Me.chkNew = True Then
        Me.AddressSubform.SetFocus
    Else
        Me.cboDate.SetFocus
    End If
End Sub
So if the checkbox gets checked, the focus gets moved to the AddressSubform, else it gets moved to a combo box called "cboDate".
 

Users who are viewing this thread

Back
Top Bottom