Author Topic: Passing controls...  (Read 2775 times)

0 Members and 1 Guest are viewing this topic.

Columbia

  • Guest
Passing controls...
« on: June 29, 2004, 11:39:52 AM »
Okay, here is my next question...

How do I pass a Form Control Object to a processing function?

I have a comboList control that I want to enable with the following function.

Code: [Select]

Public Function Enable_List(ByRef whichList As ListBox)
    whichList.Enabled = True
    whichList.ForeColor = &H80000008
End Function


Now in my Form Code i have this...

Code: [Select]

...
With UserForm1
    Enable_List (.comboListbox1)
End With
...


However, when I run my code I keep getting an Object Required error.  Mainly, because I think the argument to the function call is getting "", which is the default value of the comboList, not the comboList Control Object itself.  Does this make any sense?

So how do I get VBA to pass the object itself?

hendie

  • Guest
Passing controls...
« Reply #1 on: June 29, 2004, 11:47:12 AM »
have you tried
Code: [Select]
Public Function Enable_List(whichList As ListBox)
    whichList.Enabled = True
    whichList.ForeColor = &H80000008
End Function


and
Code: [Select]

    Enable_List comboListbox1

Columbia

  • Guest
Passing controls...
« Reply #2 on: June 29, 2004, 12:13:20 PM »
Thanks,

That help me figure it out.  It would also help, if I typed the function correctly.  It wouldn't work, because I was trying to send the Enable function a combobox not a listbox.

But I've got it now.  Thanks!