[AccessD] Checkbox dates

Gustav Brock Gustav at cactus.dk
Mon Jul 16 04:05:57 CDT 2007


Hi John et al

Sorry to disturb the romance, but you all seem to forget that a Checkbox can be set/reset by pressing +/- and toggled by pressing the spacebar.
Also, pressing a hotkey combo (Alt + a letter of the associated label) will toggle the Checkbox.

I once expanded these keypress options a bit with a subfunction you may call at the OnKeyPress event:

Private Sub chkSomeCheckbox_KeyPress(KeyAscii As Integer)

  Call CheckboxKeyPress(Me!chkSomeCheckbox, KeyAscii)
 
End Sub


Sub CheckboxKeyPress(ByRef chk As CheckBox, ByVal bytKeyAscii As Byte)

' Add more key entries than the standard (+, -, and Space)
' to set/reset or toggle the checkbox.
'
' 1998-10-08. Cactus Data ApS

  Dim booCheck As Boolean
  
  Select Case UCase(Chr(bytKeyAscii))
    ' List of key entries for set (True).
    Case "1", "Y", "T", "S", "J"
      booCheck = True
    ' List of key entries for reset (False).
    Case "0", "N", "F", "R"
      booCheck = False
    ' List of key entries for toggle.
    Case "*", "X", "C"
      booCheck = Not chk.value
    Case Else
      ' No change.
      booCheck = chk.value
  End Select
  
  ' Only change state if needed.
  If chk.value Xor booCheck Then
    chk.value = booCheck
  End If
  
End Sub

This - or at least the default OnKeyPress behaviour - could easily be incorporated in the class.

/gustav


>>> miscellany at mvps.org 15-07-2007 23:21 >>>
John,

jwcolby wrote:
> ...  I am content to have
> demonstrated how to use a class to encapsulate the behaviors required to
> perform this trick and get everyone thinking about classes and Event
> handling in classes.

I recognise that this was your initial intention, and for this I thank 
you.  Sorry if the discussion went too far off on a tangent.

Regards
Steve
-- 
AccessD mailing list
AccessD at databaseadvisors.com 
http://databaseadvisors.com/mailman/listinfo/accessd 
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list