• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

Please help with this question on using a variable to assign property value

My code is:
   'bacto = (Me.ActiveControl.Name)
                        Web1.SetFocus
                        'bacto.SetFocus
----------------------------
the "bacto.setfocus instruction does not work because it is taking "bacto" as the control name rather than the variable that "bacto" refers to .
How do I fix that so I get the control "bacto" refers to, to have focus?
0
rbend
Asked:
rbend
  • 2
  • 2
1 Solution
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Hello rbend,

Try me.controls(bacto).setfocus

Regards,

chris_bottomley
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
The bigger question is why are you using the Name() property instead of the Control itself?

Why not?

    Dim ctl As Control
    Set ctl = Me.ActiveControl

Then later:

    ctl.SetFocus

You could still use the Name property via "ctl":

    Dim ctlName As String
    ctlName = ctl.Name
0
 
rbendAuthor Commented:
sorry..didn't see the second solution before I awarded to first.
Next time.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
No problem.  Chris gave a great solution to your problem.  =)
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Glad to help

Chris
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now