Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2008

Tip: Looking for answers? Try searching our database.

Passing check box controls to a function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dennis - 19 May 2008 13:26 GMT
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
Stefan Hoffmann - 19 May 2008 13:43 GMT
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 <--
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.