Behind a form I have the same code over and over for a bunch of checkboxes:
If chkBlue = -1 Then
Blue = 1
Red = 0
End If
If chkBlue is the checkbox on the form for the field Blue in my table and there is also another field named Red in my table, when Blue's checkbox is checked, Blue is set to 1 and Red is set to 0.
That works. But how do I turn this into a Public Sub in a module?
This doesn't work:
Public Sub CheckUncheck(Chk1 As Control, CheckVar As String, UncheckVar As String)
If Chk1 = -1 Then
CheckVar = 1
UncheckVar = 0
End If
End Sub
Call CheckUncheck(chkBlue, Blue, Red)
I'm sure I'm oversimplifying it, but my Friday brain is not helping me. I can't figure out how to write it so it works.
If chkBlue = -1 Then
Blue = 1
Red = 0
End If
If chkBlue is the checkbox on the form for the field Blue in my table and there is also another field named Red in my table, when Blue's checkbox is checked, Blue is set to 1 and Red is set to 0.
That works. But how do I turn this into a Public Sub in a module?
This doesn't work:
Public Sub CheckUncheck(Chk1 As Control, CheckVar As String, UncheckVar As String)
If Chk1 = -1 Then
CheckVar = 1
UncheckVar = 0
End If
End Sub
Call CheckUncheck(chkBlue, Blue, Red)
I'm sure I'm oversimplifying it, but my Friday brain is not helping me. I can't figure out how to write it so it works.