Which reference to be added to use Recordset object in Excel VBA.
I added "Microsoft DAO 3.6 Object Library" reference but still its not working.
I tried I tried DAO.Reader,but still it is not working.
Plz help me on this.
Thank in advance
I added "Microsoft DAO 3.6 Object Library" reference but still its not working.
I tried I tried DAO.Reader,but still it is not working.
Plz help me on this.
Thank in advance
Code:
Sub t()
'Insert data in DB
Dim dbs As Object
Dim DBpath As String
Dim rst As Recordset, strSQL As String, lngRecords As Long
DBpath = "D:\abc.accdb"
Set dbs = CreateObject("Access.Application")
dbs.OpenCurrentDatabase DBpath
'Check order there in DB or not
strSQL = "SELECT * FROM Product WHERE OrderNo" _
& " ='" & Order_No & "';"
Set rst = dbs.OpenRecordset(strSQL) ----Error line say Object doesn't support this method
'Populate the Recordset.
rst.MoveLast
lngRecords = rst.RecordCount
dbs.Execute " INSERT INTO Product (OrderNo)" _
& " values('" & Order_No & "')"
dbs.Close
End Sub