The following Code is causing an error when I try to set the AdoConn = New Connection. I receive an "Invalid Use of New Keyword" error. Can I get some guidence as to why? Thanks.

Dim adoRecordset As Recordset
Private Sub Form_Load()
    Dim adoConn As Connection
    Set adoConn = New Connection
    Dim str As String
    Dim sqlName As String
    Me.Caption = "Company Database"
''    Set adoConn = Nothing
'Next three lines opens the Jones.mdb database.
    adoConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Jones.mdb;Persist Security Info=False"
    Set adoRecordset = New Recordset
    str = "select * from tblToDo"
    adoRecordset.Open str, adoConn, adOpenDynamic, adLockOptimistic

Hi, I think no error here. I check it out. But try this

'Instead of using

Also try ADODB.RecordSet


Recordset also need to be decalred as New..

Dim adoRecordset As New ADODB.Recordset

also give Full Path of the Database in connection string..


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.