- Local time
- Today, 14:35
- Joined
- Feb 19, 2013
- Messages
- 17,064
For whatever reason, checkbox controls cannot be resized. This suggestion addresses that issue and also enables the use of colour.
To create, put the following in the format property of a textbox and set the control source to a boolean value
1. set format property - [[Blue]\R;[Green]\R;[Red]\S;©
2. set font - wingdings
3. set font size as required - suggest 16 if normal font size is ll
4. set border to transparent
5. set enabled=no
6. set locked=yes
7. set tab stop to No
note enabled=no and locked=no will 'grey out' the control so colours are removed.
sometimes you might want null or false to be represented by an empty square box in which case change the S or © in the format string to £ (chr163)
I've included a 'blue tick' because any number other than 0 is 'true' and you might want to differentiate between -1 and another value such as a count.
if the underlying field is required to be updateable then set enabled=true and in the onclick event put
locked only prevents users from manually entering data, not changes made by clicking
However this creates a presentational issue as the control now has the focus and will be trying to display the actual underlying value, so we need to move the focus elsewhere. You may have a control you can move it to. If not, create an unbound textbox called say 'txtFocus' and set top, left, width and height properties to 0. Then modify the control click event to
and in the control doubleclick event put
txtfocus.setfocus
to prevent the cursor staying on the control
Finally, you may have an issue that the control receives the focus when the form opens. If so, change the tab order so another control receives the initial focus - or create the txtFocus control, set the tab index to 0 and tab stop to yes
Edit: For a more system-wide solution, providing you are prepared to have the txtFocusControl on the form, the click event code can be put in a module
and then called by putting =chkBoxChange() against the click event (replacing [Event Procedure])
I attach a file to illustrate
To create, put the following in the format property of a textbox and set the control source to a boolean value
1. set format property - [[Blue]\R;[Green]\R;[Red]\S;©
2. set font - wingdings
3. set font size as required - suggest 16 if normal font size is ll
4. set border to transparent
5. set enabled=no
6. set locked=yes
7. set tab stop to No
note enabled=no and locked=no will 'grey out' the control so colours are removed.
sometimes you might want null or false to be represented by an empty square box in which case change the S or © in the format string to £ (chr163)
I've included a 'blue tick' because any number other than 0 is 'true' and you might want to differentiate between -1 and another value such as a count.
if the underlying field is required to be updateable then set enabled=true and in the onclick event put
Code:
if not mycontrol.locked then mycontrol=not nz(mycontrol,false)
However this creates a presentational issue as the control now has the focus and will be trying to display the actual underlying value, so we need to move the focus elsewhere. You may have a control you can move it to. If not, create an unbound textbox called say 'txtFocus' and set top, left, width and height properties to 0. Then modify the control click event to
Code:
txtFocus.setfocus
if not mycontrol.locked then mycontrol=not nz(mycontrol,false)
and in the control doubleclick event put
txtfocus.setfocus
to prevent the cursor staying on the control
Finally, you may have an issue that the control receives the focus when the form opens. If so, change the tab order so another control receives the initial focus - or create the txtFocus control, set the tab index to 0 and tab stop to yes
Edit: For a more system-wide solution, providing you are prepared to have the txtFocusControl on the form, the click event code can be put in a module
Code:
Function chkBoxChange()
If Not Screen.ActiveControl.Locked Then Screen.ActiveControl = Not Nz(Screen.ActiveControl, False)
Screen.ActiveControl.Parent.txtFocus.SetFocus
End Function
and then called by putting =chkBoxChange() against the click event (replacing [Event Procedure])
I attach a file to illustrate
Attachments
Last edited: