GKIL67
Technical User
- Dec 1, 2009
- 44
Hello all, I'm trying to simulate a numeric pad where values
range from 1 to anything, no gaps - via an ms access form.
My issue is how to avoid repeating the subs for each
toggle button, as for i.e. 100 buttons I have to add
and modify 100 subs.
Also, how to empty the string from the respective value
(see HELP! remark below).
Any good ideas? Kindly check my code below.
Thank you!
================================================
range from 1 to anything, no gaps - via an ms access form.
My issue is how to avoid repeating the subs for each
toggle button, as for i.e. 100 buttons I have to add
and modify 100 subs.
Also, how to empty the string from the respective value
(see HELP! remark below).
Any good ideas? Kindly check my code below.
Thank you!
================================================
Code:
Option Compare Database
Private Sub ToggleButton01_Updated(Code As Integer)
My_Result = GetToggle(ToggleButton01)
End Sub
Function GetToggle(AllToggleFields As Control)
'Used by all toggle buttons
Dim strActiveCtl As String
Dim ToggleVal As Integer
Me!SumValue = 0
strActiveCtl = Screen.ActiveControl.Name
If AllToggleFields.Value = False Then
AllToggleFields.BackColor = -2147483633 'gray
AllToggleFields.BorderColor = 0
Me!SelectedValues = Me!SelectedValues & "," & Right$(strActiveCtl, 2) 'HELP!
Me!SumValue = Me!SumValue - Val(Right$(strActiveCtl, 2))
If Me!SumValue < 0 Then Me!SumValue = 0
Else
AllToggleFields.BackColor = 255 'vbRed
AllToggleFields.BorderColor = 255
Me!SelectedValues = Me!SelectedValues & "," & Right$(strActiveCtl, 2)
Me!SumValue = Me!SumValue + Val(Right$(strActiveCtl, 2))
End If
Set AllToggleFields = Nothing
End Function