I want to call a function in a module from a button press on a form. I want
to pass the name of a check box control on my form into this function and
then use this in my function to uncheck the check box on the form. How do I
pass it and and how do I reference it in my function ?
I do this because I have several check boxes on the form and I wanted 1
common routine in a module with variables passed into it.
e.g. Call MyFunction(chkQ1)
Public Function MyFunction (ctlChkBox as Checkbox)
Forms!MyForm!ctlChBox = False
End Function
hi Dennis,
> I do this because I have several check boxes on the form and I wanted 1
> common routine in a module with variables passed into it.
[quoted text clipped - 4 lines]
> Forms!MyForm!ctlChBox = False
> End Function
You have the following two possibilities:
--
Option Compare Database
Option Explicit
Private Sub cmdChangeCheckBox_Click()
byName "yourCheckBox"
byControl yourCheckBox
End Sub
Private Sub byName(ACheckBoxName As String)
Dim ac As Access.Control
Set ac = Me(ACheckBoxName)
If TypeOf Me(ACheckBoxName) Is Access.CheckBox Then
ac.Value = True
End If
Set ac = Nothing
End Sub
Private Sub byControl(ACheckBox As Access.CheckBox)
ACheckBox.Value = False
End Sub
--
mfG
--> stefan <--
Dennis - 19 May 2008 13:55 GMT
Thanks, the 2nd one is the one I wanted
> hi Dennis,
>
[quoted text clipped - 40 lines]
> mfG
> --> stefan <--