Toggle button with no background

driver7408

Registered User.
Local time
Today, 01:19
Joined
Feb 7, 2010
Messages
72
I am making a specialty form where it must toggle on or off when the user clicks on a boxed area. Since toggle backgrounds cannot be set to transparent, I need to do it some other way. I thought of either using a button to control a hidden checkbox, or just writing code altogether. The problem is that I don't know what code to use to programatically change the state each time the box is clicked.

Any suggestions on this?

Thanks.
 
You mean like:

Me.Checkbox = Not Me.Checkbox
 
You mean like:

Me.Checkbox = Not Me.Checkbox


No I mean something to the effect of

On Click
If RemoteCheckbox= True Then
RemoteCheckbox = False
If Remote Checkbox =False Then
Remote Checkbox=True
 
You didn't try what I posted, did you?
 
You didn't try what I posted, did you?


No. I used :

If IsNull(Me.Check219) Then
Me.Check219 = True
Else
If Me.Check219 = False Then
Me.Check219 = True
Else
If Me.Check219 = True Then
Me.Check219 = False
End If
End If
End If
End Sub
 
Whatever floats your boat. I'd rather do it with one line.
 
At a time I have had a boss - an engineer (all my respect for he).
Sometimes, after he listen my mechanical "solution" he said:
Yes Mihail. Good for you ! Why simple if you can complicate ?

Paul's code (post #2) do exact the same with only one line of code.
More: Inform us, please, if your check box will ever be Null :)

Good luck !
 
At a time I have had a boss - an engineer (all my respect for he).
Sometimes, after he listen my mechanical "solution" he said:
Yes Mihail. Good for you ! Why simple if you can complicate ?

Paul's code (post #2) do exact the same with only one line of code.
More: Inform us, please, if your check box will ever be Null :)

Good luck !
I'm honestly not familiar with the purpose and function of the not me. checkbox code. User will NOT be clicking on the checkbox, they will be clicking on a button that cycles the checkbox on and off.

More: The checkbox is null when the form opens. It has no recordsource. It is only being used for reference that will later be handled by an IIF statement.
 
Last edited:
Indeed. My bad. An unbound check box can be null.

Amend Paul's formula:
Me.Checkbox = Not Nz(Me.Checkbox,0)
 
Or simply give it a default value.
 
Or simply give it a default value.


That's not a bad idea. Anyways, can you explain how your code relates to what I am trying to do? I am not very experienced with VB yet, but I am always trying to learn when I can, and I know you are one of the best programmers in here, as I have used your advice in other people's threads many times over the past few years.
 
Last edited:
There are 2 things here.

If you need for some reasons to have a Null value for that check box when you open the form and to change it to True (checked) ONLY when a certain event is fair then post #10 will do the trick.

But, if you wish that that check box to be True (checked) when you first open the form then, select the check box (in Design View), go to Property Sheet, "Data" tab and, in the row "Default Value" write "-1" (without quotes).
Then use first Paul's formula in order to toggle between checked and unchecked.
 
Checkbox is invisible. Not seen by the user, not clicked on by the user. I am using a checkbox because the toggle switch cannot be made transparent. Instead I am using a transparent button. When that transparent button is clicked, it changes the status of the checkbox so the IIF code can evaluate properly later. Its a unique form with a bunch of smoke and mirrors that looks like the normal, paper version to the user.

Checkbox can be default null or zero on load.

I am up to just over 500 estimated controls on the form so far, and it still loads quickly and works as advertised.
 
Checkbox is invisible.
So, you use that check box as a container where you store a boolean value.
Faster and cleaner: use a boolean variable in VBA.
 

Users who are viewing this thread

Back
Top Bottom