• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • 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 BottomleyCommented:
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 BottomleyCommented:
Glad to help

Chris
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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