Access 97 passing object ref to subroutine

guy.murray

New member
Local time
Today, 20:28
Joined
Dec 1, 2006
Messages
7
Hi,
am trying to pass a textBox object (Text1) to a subroutine as in the following simplified eg...

Public Sub testSub(objRef As Object)
MsgBox objRef.Value
End Sub

Private Sub Text1_AfterUpdate()
testSub (Text1)
End Sub

This just produces an "Object required" Run-time error "424"

Can someone tell me where I'm going wrong?

many thanks

Guy
 
i think a text box is a control so the function should be something like

Public Sub testSub(ctrlref as control)
MsgBox (ctrlref.name & " " & ctlref.Value)
End Sub
 
Thanks for replying.

Produces the same error message.

Curiously, putting "msgbox text1.Value" before calling the subroutine behaves as one would expect. The Subroutine seems to treate the object reference as synonymous with its Value property.

I wonder what happens with later versions of Access, I'm stuck with '97.

Guy
 
yeah

i assumed this would work, but i've just spent 20 minutes playing with it, and I'm getting the same result as you.

i've definitely used this construct in later versions of Access, but i'm not sure now about Access 97.

sorry
 
Private Sub Text1_AfterUpdate()
Call testSub (Text1)
End Sub

peter
 

Users who are viewing this thread

Back
Top Bottom