corpuschristi
New member
- Local time
- Today, 05:03
- Joined
- Jun 23, 2008
- Messages
- 4
First timer here, so, naturally, feeling you may find my question trivial, as my familiarity with vb programing is poor, but please bear with me. And please excuse my English.
I'm building a form, containing hundreds of labels. Now, i want to create a function that changes the background color of a label to red, when clicked upon, and back to white when clicked again, and so on.
I created a module, so far it looks like this:
Function PaintCell(ObjName As Object)
If (ObjName.BackColor = RGB(255, 255, 255)) Then
ObjName.BackColor = RGB(255, 0, 0)
Else
ObjName.BackColor = RGB(255, 255, 255)
End If
End Function
It works fine, BUT
I want each of the 24x24 (576) labels to call the same function when clicked (event-when clicked: =PaintCell(forms!formname!objectname)). I'm trying to save some work. Sure, i could go through each of the labels and change the event, the parameter of the function to the full object path, but it would take hours. Is there a way for a function to identify the object (for this matter, the label) who'd called it, and then execute commands on it, without its name recieved as parameter? This way, i could just create a single label, set everything, then COPY-PASTE it to create as many as i need.
If it can be done, or if there are other possibilities, i would be grateful for any assistence.
Andrej.
I'm building a form, containing hundreds of labels. Now, i want to create a function that changes the background color of a label to red, when clicked upon, and back to white when clicked again, and so on.
I created a module, so far it looks like this:
Function PaintCell(ObjName As Object)
If (ObjName.BackColor = RGB(255, 255, 255)) Then
ObjName.BackColor = RGB(255, 0, 0)
Else
ObjName.BackColor = RGB(255, 255, 255)
End If
End Function
It works fine, BUT
I want each of the 24x24 (576) labels to call the same function when clicked (event-when clicked: =PaintCell(forms!formname!objectname)). I'm trying to save some work. Sure, i could go through each of the labels and change the event, the parameter of the function to the full object path, but it would take hours. Is there a way for a function to identify the object (for this matter, the label) who'd called it, and then execute commands on it, without its name recieved as parameter? This way, i could just create a single label, set everything, then COPY-PASTE it to create as many as i need.
If it can be done, or if there are other possibilities, i would be grateful for any assistence.
Andrej.