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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call Sub Routines

Status
Not open for further replies.

webstony

Technical User
Jan 29, 2001
19
DE
Hello everybody,

new day, new problem. ;-)
i am using forms and a lot of checkboxes in my vba-word-script. so i wonder myself, if there is a possibility to do things easier.

my code:

Sub main()
Call Transfer1(CheckBox1)
Call Transfer1(CheckBox2)
...
End Sub

Sub Transfer1(myBox As CheckBox)
myBox.Value = -1
...
End Sub

But with my code an Error occurs. valid Call-by-reference! How can I solve this??

Thanks in Advance,
cu, stony
 
Your problem is that your are passing the value of the checkbox not the object.

I had trouble trying to send it the object, not sure if you can do it that way. Try this instead.

Pass the Sub the name of the checkbox.

Private Sub Main()
Call transfer(CheckBox1.Name)
Call transfer(CheckBox2.Name)
End Sub

Private Sub transfer(ChkBoxName As String)
UserForm1.Controls.Item(ChkBoxName).Value = -1
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top