I am facing a strange error while connecting Access DB using VBA. The VBA code goes like this:
Sub DBC()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Bmcstr01\grp\SRV\Allsrv\Resource Planning\Forecasting & MI\MI\backup DM\HH Complaints\Database (TCS Version)\Complaints DB.accdb;"
Set rs = New ADODB.Recordset
rs.Open "Access_Log", cn, adOpenKeyset, adLockOptimistic, adCmdTable
rs.Filter = "ID='335266' AND Work='Test'"
rs("Login").Value = "02/07/2018"
rs.Update
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
The error it is giving is: "Compile Error: User define type not defined" and it is pointing to first line of the sub.
My table is present in the DB. It structures as follows:
ID Login Work
335266 04/07/2018 Test
335266 03/07/2018 Test2
Can anyone please help me with the reason why it is not accepting the ADODB and how to resolve this?
Set cn = New ADODB.Connection
? – Skindeep