Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Userform Control referencing

  Asked By: Loretta    Date: Oct 26    Category: MS Office    Views: 659
  

How can I reference the current control using a generic variable.

The extract below indicates what I am trying to achieve, but just does
not work.

dim mvCtrl as control
mvControl = me.activeControl.name

If mvCtrl.value .....

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Michele Grant     Answered On: Oct 26

mvCtrl is an object variable. To assign a control  to an object variable, you
must use the Set statement:

Dim mvCtrl As Control
Set mvCtrl = Me.ActiveControl
MsgBox mvCtrl.Value

When you are done with an object variable, you should free memory used by it
with another Set command:

Set mvCtrl = Nothing

 
Answer #2    Answered By: Aberto Rossi     Answered On: Oct 26

What actually happens? Do you get an error message?

 
Answer #3    Answered By: Nina Garcia     Answered On: Oct 26

Don't know if you copied your code into the eMail or retyped it.
I think you retyped it due to the lower case on dim, me, and
activeControl.name

Not that this is your problem.

Might try keeping your names the same:

dim mvCtrl as control
mvControl = me.activeControl.name

If mvCtrl.value .....

SHOULD READ:

dim mvCtrl as control
mvCtrl = me.activeControl.name

If mvCtrl.value .....

 
Didn't find what you were looking for? Find more on Userform Control referencing Or get search suggestion and latest updates.




Tagged: