form-based macro for checkboxes on a sheet


Posted by Click on February 23, 2001 5:03 AM

i have a label on a userform, and i want the caption of the label to trigger a check/uncheck of a check box on a worksheet when a button on the userform is pressed, i tried to record a macro to check the box then add that code into the macro but it won't let me, does anyone have any idea how this can be achieved? if you do please reply here or e-mail me, thanks very much for anything you can do...Click

Posted by Dave Hawley on February 23, 2001 5:25 AM


Hi Click

Try this code. it uses the sheet CodeName of the sheet housing the CheckBox. The code name of each sheet can be seen in the "Project explorer", it's the one NOT in brackets.


Private Sub Label1_Click()

If Sheet1.CheckBox1.Value = True Then
Sheet1.CheckBox1.Value = False
Else
Sheet1.CheckBox1.Value = True
End If

End Sub

Posted by Dave Hawley on February 23, 2001 5:26 AM


Hi Click

Try this code. it uses the sheet CodeName of the sheet housing the CheckBox. The code name of each sheet can be seen in the "Project explorer", it's the one NOT in brackets.


Private Sub Label1_Click()

If Sheet1.CheckBox1.Value = True Then
Sheet1.CheckBox1.Value = False
Else
Sheet1.CheckBox1.Value = True
End If

End Sub

Dave

OzGrid Business Applications

Posted by Click on February 23, 2001 6:17 AM

Thanks very much that works perfectly, couldn't have done it without you :-)



Posted by Roger on February 23, 2001 6:40 AM

You could try recording a macro to check the box and link it to another macro which adds the code. But that won't work you say? No, but if you download a program called SecLink to link your macros it will help you do everything easier. Only problem is if you are doing this for someone else and they dont have the program on their machine. But if you link the macros and then use the binding fuction in SecLink it will put them together and it should now work. The link is below and you can download SecLink at the bottom of the page, It is only about 700K. Hope it helps you.