label type mismatch error

Summer123

Registered User.
Local time
Today, 00:33
Joined
Feb 9, 2011
Messages
216
ok this should be pretty easy but getting an error that i cant seem to understand.. i have a label where if i click on it, it should check off 2 boxes and if i click on it again it should clear both. here is what i am coding too but its giving me a type mismatch error, what am i doing wrong here?

also is there a way to underline the label when the mouse is over it so the user knows to click it?

Private Sub selectclrall7_Click()
If selectclrall7.OnClick = True Then 'this is where it highlights the code
checkbox1.Value = True
checkbox2.Value = True
End If
If selectclrall7.OnClick = False Then
checkbox1.Value = Flase
checkbox2.Value = False
End If
End Sub
 
thank you, so if i want it so that when the lable is clicked it checks the 2 boxes is it doable? I am doing this through toggle button right now, it works fine however the form is very conjusted and not user freindly and so i thought to see if I can use a label instead. can i do this through a label and if so do u have any pointers, the link you posted did not help me much... thank you again
 
I think we can do this differently. In fact I have done something similar with the Command Button click:Double-Action Command Button

The trick works with changing the Caption of the Label interchangably and checking it each time to decide what to do, when the user clicks on it.

Example: Edit/Lock state of a form.

  1. Initialy let us set the caption of the Label as Edit so that user clicks on the label to edit the contents of the form, initially kept in Lock State.
  2. The click event procedure can check the Caption of the Label (If Me.lblEditLock.Caption = "Edit" Then), if it is Edit unlock the form to edit and change the Caption of the Label to Lock indicating that the user should click on the label again to lock the form. On the Current event procedure of the form also can be used to lock the form, in case the user forgot to do it.
  3. When the user clicks on the label with the caption Lock; lock the form and change the caption back to Edit.

Use the link Double-Action Command Buttonfor details on this method.
 
Code:
If checkbox1 = False Then
   checkbox1.Value = True
   checkbox2.Value = True
Else
   checkbox1.Value = Flase
   checkbox2.Value = False
End If

Or you could check both checkboxes.

:edit:

re: the above post - the .Tag property is good for this, in fact it's pretty much perfect as it can hold 2000 odd chars worth of data about a control without effecting the way anything works.

Simply storing true or false in there and alternating it should be as easy as:

Code:
If selectclrall7.tag = "False" Then
   checkbox1.Value = True
   checkbox2.Value = True
   selectclrall7.Tag = "True"
Else
   checkbox1.Value = Flase
   checkbox2.Value = False
   selectclrall7.Tag = "False"
End If
 
thank you both apr pillai and CBrighton!

Code:
If checkbox1 = False Then
   checkbox1.Value = True
   checkbox2.Value = True
Else
   checkbox1.Value = Flase
   checkbox2.Value = False
End If
CBrighton the solution you have given regarding the above works, however now its done in three clicks instead of 2. So since we have if the checkbox1 = false, its looking for it to be in the false state, but since when the form is started the checkbox is in a greyed out mode (not checked or unchecked) so in the first click it clears it, then checks it and then clears it again. My question is, how do i set the checkboxes to a clear state when the form loads?
 
never mind i figuered it out.. i had to code it so that when the form loaded the checkboxes were in the false state..
 

Users who are viewing this thread

Back
Top Bottom