Hi,
i have a database with extension .accdb. In the VBA code for Save button, following code is written.
However, it keeps giving error at 'ADODB.Connection' as 'Method or data member not found' while highlighting the .connection word. I have checked the References section. I believe all relevant references are selected there (see the attached picture). So why is it stuck there? What should be done or changed so as to make the code working? Your help is really appreciated.
i have a database with extension .accdb. In the VBA code for Save button, following code is written.
Code:
' Create Variables
Dim cnn1 As ADODB.Connection
Dim rstcontact As ADODB.Recordset
Dim strCnn As String
' Open a connection.
Set cnn1 = ADODB.Connection
mydb = "D:\filepath\db1.accdb"
strCnn = "Provider=Microsoft.ACE.OLEDB.14.0;Data Source=" & mydb
cnn1.Open strCnn
' Open table.
Set rstcontact = New ADODB.Recordset
rstcontact.CursorType = adOpenKeyset
rstcontact.LockType = adLockOptimistic
rstcontact.Open "tbl001", cnn1, , , adCmdTable
However, it keeps giving error at 'ADODB.Connection' as 'Method or data member not found' while highlighting the .connection word. I have checked the References section. I believe all relevant references are selected there (see the attached picture). So why is it stuck there? What should be done or changed so as to make the code working? Your help is really appreciated.