Changing Control Reference

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the best way to move the reference from one control to another
control, based upon the entry in the first control. I am trying to formulate
a type of if then statement but can't get it to work. What I would like to
happen is:
If [Control1] = "yes" goto [Control5], If [Control1] = "no" goto [Control6],
If [Control1] = "null" goto [Control7].
 
Just a few lines of code in the Before Update or After Update event of
Control1:

Dim ctl As String
Select Case Me.Control1
Case "Yes"
ctl = "Control5"
Case "No"
ctl = "Control6"
Case Is Null
ctl = "Control7"
End Select
Me.Controls(ctl).SetFocus


HTH,
Nikos
 
I placed this code in the after update event procedure control, but am still
having problems with the last line. Am I missing something?

Private Sub Leakage_Y_N_AfterUpdate()

Dim Ctl As String
Select Case Me.Leakage_Y_N
Case "Yes"
Ctl = "LossLeak"
Case "No"
Ctl = "General Comments"
End Select
Me.Controls.Leakage_Y_N.SetFocus

End Sub

rbb101 said:
Thanks. I figured there was an easy way to do it...Just couldn't figure it
out.

rbb101 said:
What is the best way to move the reference from one control to another
control, based upon the entry in the first control. I am trying to formulate
a type of if then statement but can't get it to work. What I would like to
happen is:
If [Control1] = "yes" goto [Control5], If [Control1] = "no" goto [Control6],
If [Control1] = "null" goto [Control7].
 
To move the focus to the control whose name has been specified by your
Select Case:
Me.Controls(Ctl).SetFocus

HTH,
--
George Nicholson

Remove 'Junk' from return address.


rbb101 said:
I placed this code in the after update event procedure control, but am
still
having problems with the last line. Am I missing something?

Private Sub Leakage_Y_N_AfterUpdate()

Dim Ctl As String
Select Case Me.Leakage_Y_N
Case "Yes"
Ctl = "LossLeak"
Case "No"
Ctl = "General Comments"
End Select
Me.Controls.Leakage_Y_N.SetFocus

End Sub

rbb101 said:
Thanks. I figured there was an easy way to do it...Just couldn't figure
it
out.

rbb101 said:
What is the best way to move the reference from one control to another
control, based upon the entry in the first control. I am trying to
formulate
a type of if then statement but can't get it to work. What I would
like to
happen is:
If [Control1] = "yes" goto [Control5], If [Control1] = "no" goto
[Control6],
If [Control1] = "null" goto [Control7].
 
Back
Top