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 / New Users / May 2004

Tip: Looking for answers? Try searching our database.

Passing a reference of a object on a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AdmSteck - 28 May 2004 17:51 GMT
I have this code on one form

Private Sub Owner_DblClick(Cancel As Integer
On Error GoTo Err_Owner_DblClic
   Dim lngOwner As Lon
   If IsNull(Me![Owner]) The
       Me![Owner].Text = "
   Els
       lngOwner = Me![Owner
       Me![Owner] = Nul
   End I
   DoCmd.OpenForm "Who Entry
   Me![Owner].Requer
   If lngOwner <> 0 Then Me![Owner] = lngOwne
Exit_Owner_DblClick
   Exit Su
Err_Owner_DblClick
   MsgBox Err.Descriptio
   Resume Exit_Owner_DblClic
End Su

But I would like to modify it and place it in a class module so I can use it on several forms.  How do I pass a reference of the combobox "Owner" to the function in the module so that I can replace all the me![owner]?
Dan Artuso - 28 May 2004 19:24 GMT
Hi,
The signature would be:
Public Sub YourFunction(ctl As ComboBox)
   'then just substitute ctl where ever you used Me![Owner]
End Sub

HTH
Dan Artuso

> I have this code on one form:
>
[quoted text clipped - 18 lines]
>
> But I would like to modify it and place it in a class module so I can use it on several forms.  How do I pass a reference of the combobox "Owner" to the function in the module so that I can replace all the me![owner]?
George Nicholson - 28 May 2004 20:10 GMT
This is untested.

Me!Owner refers to the underlying recordset field and not the combobox
itself so adjustments may be necessary, but hopefully this will get you
started.

Private Sub Owner_DblClick(Cancel As Integer)
   Call CheckOwner(Me.cboOwner)
End Sub

Public Sub CheckOwner(cbo as ComboBox)
    On Error GoTo ErrHandler
    Dim lngOwner As Long
    If IsNull(cbo) Then
        cbo.Text = ""
    Else
        lngOwner = cbo
        cbo = Null
    End If
    DoCmd.OpenForm "Who Entry"
    cbo.Requery
    If lngOwner <> 0 Then cbo = lngOwner
ExitHere:
    Exit Sub
ErrHandler:
    MsgBox Err.Description
    Resume ExitHere
End Sub

Signature

George Nicholson

Remove 'Junk' from return address.

> I have this code on one form:
>
[quoted text clipped - 18 lines]
>
> But I would like to modify it and place it in a class module so I can use it on several forms.  How do I pass a reference of the combobox "Owner" to
the function in the module so that I can replace all the me![owner]?
 
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.