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

Passing object references

Status
Not open for further replies.

SKILTC

IS-IT--Management
Apr 3, 2001
6
US
I have 28+ toggle buttons that when 'clicked' will change color and update an unbound field by adding 1, (if its value is "-1") else it will revert to the original color and update the unbound field by subtracting 1. Is there a way I can write this code once in a public area and use the call function from each control? I do not know how to pass the name of the control that is calling the function.

I am trying to avoid adding this code to each button. Any help would be great.

Private Sub Toggle27_Click()
Dim thecontrol As Control
thecontrol = "[Toggle27]"
Call schdpick

end sub

Private Sub schdpick()
Dim thecontrol as Control

If thecontrol = -1 Then
test = "On"
thecontrol.FontBold = True
thecontrol.ForeColor = 16744448
test.Requery
Else
test = "Off"
thecontrol.FontBold = False
thecontrol.ForeColor = -2147483630
test.Requery
End If
End Sub
 
Code:
Private Sub Toggle27_Click()
Call schdpick (Toggle27)

end sub

Private Sub schdpick(theControl as control)
If thecontrol.Value = true Then ' I assume value is default property
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top