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]?