Trouble getting Textbox as Checkbox to function

JMongi

Active member
Local time
Today, 03:54
Joined
Jan 6, 2021
Messages
802
See this thread by @CJ_London for reference:

The formatting doesn't appear to be working as intended.
Clicking on the form control still tries to enter text in the field even when locked.
 
I have this in the Format portion of the text box property:
[Blue]\R;[Green]\R;[Red]\S;©

I have Font Name: Wingdings 2
I have Border Style: Transparent
I have Enabled: Yes
I have Locked: Yes
I have Tab Stop: No
I have Default: True
I have Source: Running (a Yes/No field)

I have the following in the Click event of the textbox and I do have a textbox called txtFocus on my form:
Code:
Private Sub txtRunning_Click()

txtFocus.SetFocus
If Not txtRunning.Locked Then
    txtRunning = Not Nz(txtRunning, False)
End If

End Sub

The look of the checkmark is not a checkmark. So I presume some mapping of characters to symbols is off.
Also, double clicking on the control puts the cursor in there still.
 
hmm, surprised no one has mentioned it before -try the wingdings font, you are looking for chr 253 and 254
image_2022-10-28_173431491.png



with regards
Also, double clicking on the control puts the cursor in there still.

think you will need to put the same code into the double click event
 
Last edited:
So, I might be missing something obvous here.
Am I supposed to set the text value via VBA on a click? Is that supposed to happen automatically?
I'm not sure what your format string is doing so it makes it a little tougher for me to take educated guesses to try and troubleshoot.
 
It’s not a text value but a Boolean value- and the code changes it from true to false or false to true

it’s positive;negative;zero;null for number type data types (booleans and dates are also number types)
 
So, I broke some things down to troubleshoot. We can worry about wingdings later. I focused on having the textbox display a standard text based on the MS help file above and @Pat Hartman first comment and setting the default value to True/False/Null. I arrived at the following conclusion.

For formatting it goes ;"Text for True"[Color];"Text for False"[Color];"Text for Null"[Color]
This gets converted by Access to ;\Text for True[Color];\Text for False[Color];\Text for Null[Color]
 
I adapted some code I made for creating an option group out of command buttons to work as a checkbox. (A command Button as a checkbox)

Nifty Check Box - Over View 1​

 
Last edited:
I've corrected my original thread (not sure what went wrong with the format string, it is almost as if the characters have changed since I can't find the character for null anymore) and attached an example. Also attached here,

see this link for the fonts as per the original post, showing the original values for P etc
 

Attachments

@JMongi, I also made a video to use a unicode character in a textbox for YesNo here that might give you some ideas:

Big Checkbox in Access with Conditional Formatting
 
Using Win10 & set Character Map utility for "WingDings 2", the checkmark is 0x50, checkmark-in-a-box is 0x52. X-mark is 0x4F, x-in-a-box is 0x51. These would be upper-case O(=0x4F), P, Q, R(=0x52) as codes go.

Win10, set Character Map to "WingDings" (no 2), checkmark is 0xFC, check-in-a-box is 0xFE, X-mark is 0xFB, x-in-a-box is 0xFD. These characters have no corresponding characters in standard ASCII, which stops at 0x7F, but CHR$(0xFC) would work correctly.

Therefore, the check-mark and x-mark appear in both fonts but in different places. Those characters do not appear (that I can see) in Webdings or in WindDings 3.
 
indeed!

decimal Unicode character for ChrW

9744 ☐ BALLOT BOX Checkbox open
9745 ☑ BALLOT BOX WITH CHECK Checkbox checked
9746 ☒ BALLOT BOX WITH X Checkbox X
 
The issue is the char allocation appears to have changed, at least for the OP and myself - I’ve started another thread on the subject. Two responses indicate it does not affect everyone
 
Well I am on 2007, so pretty ancient? :)
 
actually, you don't even have to do all that ... if the Data Type is Integer instead of YesNo, you can set Format to something like this (the Format property supports Unicode):

☑[Magenta];☑[Red];☐[Blue];--

btw, it seems that Yes/No is actually stored as an integer -- but capabilities have been crippled. Read this from Allen Browne:

Why I stopped using Yes/No fields, by Allen Browne
 
I am so glad I just used the checkbox as is when I needed one . :-)
 
I've resolved the problem - turned out my form had a corruption -recreating the form resolved the issue - link updated
 
Last edited:
Thanks to all the replies. I have to take care of some other responsibilities and will come back to this later. So, I don't have time to review all the linked information right now.

@The_Doc_Man - I tried to sort some things out using CharMap and I don't understand the character codes or how to use them in this context to identify a character. I'll google it in a bit. Just wanted to let everyone know.

@strive4peace - Similar statement to above. I tried copying the appropriate characters out of the wingding font set in CharMap and it got converted in the format property and then didn't resolve correctly when loading the form. I'm not 100% clear on what "using unicode characters" means.

Thanks again! When I get back to this, I'll post a resolution or more questions.
 

Users who are viewing this thread

Back
Top Bottom