Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Correct syntax for passing controls as arguments 1

Status
Not open for further replies.

Maquis

Programmer
Jul 19, 2001
934
US
Can someone please help me figure out the correct syntax for this module. I've been struggling with it for the past hour an it's about to drive me crazy.

I have the following Subroutine defined in my form...
Code:
Private Sub ControlDisable(ctl As TextBox)
    ctl.Locked = True
    ctl.Enabled = False
    ctl.SpecialEffect = 0   'flat
    ctl.BackStyle = 0       'transparent
    ctl.BorderStyle = 0     'transparent
End Sub

And I'm calling it from another subroutine in the same form like so..
ControlDisable (Me.Controls("AdjName"))

However, I keep receiving an error 424 "Object required".
AdjName is the name of a textbox on this form, so I know that isn't the problem.

Any ideas?

Maq [americanflag]
<insert witty signature here>
 
Try calling it like this:

ControlDisable (AdjName)

or like this

ControlDisable (Me!AdjName)
 
Nope, I still get the same error. Actually, I had that syntax in there first, but later changed it to the me.controls() format.

Now, you see why I'm frustrated! [evil]

Maq [americanflag]
<insert witty signature here>
 
I think I know what your problem is. It's how you are calling the sub. The syntax should be either

Call ControlDisable(AdjName)

or

ControlDisable AdjName

But not

ControlDisable (AdjName) 'Note the parenthesis
 
Yayy! That did it.[thumbsup2]

Sorry, I should have seen that. Those parentheses trip me up everytime.

Ok, now onto the 50 other problems my boss wants me to solve today. [pc1]

Is it Friday yet?

Maq [americanflag]
<insert witty signature here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top