Object missing?? in an ADO open connection CLASS - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Object missing?? in an ADO open connection CLASS

eatc7402eatc7402 Posts: 15Member
I have the following code in a MODULE.

' Open a connection.
Set myconn = New ADODB.connection
myconn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DB_Path_File_param & ";" & _
"Persist Security Info=False"
myconn.CursorLocation = adUseClient

ListFields(myconn, tbl_or_qry_selected_item)

It works fine.

I then attempted to make the 'open connection' code
into a CLASS, like this:
Public Function Open_ADO_conn_to_Jet(Path_Filename As String) As Object
Dim connection As ADODB.connection
' Open a connection.
Set connection = New ADODB.connection
connection.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Path_Filename & ";" & _
"Persist Security Info=False"
connection.CursorLocation = adUseClient

Open_ADO_conn_to_Jet = connection

End Function

and THEN call the function with this
Set DB_Hookup_dbf = New DB_Class_dbf

Set myconn = DB_Hookup_dbf.Open_ADO_conn_to_Jet (DB_Path_File_param)

The DB_Path_File_param passed is okay.

BUT this results in a 424 Runtime error, of OBJECT REQUIRED. I am somewhat miffed
by just what I have done incorrectly here. Where am I missing an object here?



  • infidelinfidel Posts: 2,900Member
    [b][red]This message was edited by infidel at 2006-6-21 7:10:52[/red][/b][hr]
    : Open_ADO_conn_to_Jet = connection

    You forgot the "Set".

    Also, the class is named Connection, and it's not a good idea to name a variable the same name as a class or type. This may not be an actual problem with your code in this case, but it's still not a good idea.


    $ select * from users where clue > 0
    no rows returned

Sign In or Register to comment.