Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ADODB doesn't exist in Access 2013 project, how do I add a reference to it

I am trying to rebuild an Access adp project in Access 2013 as and mdb. The tables are all linked tables in both version so that is not an issue.

I have imported the forms from the old project so the form layouts and code is all there.

Where I run into problems is when trying to execute the following code:

Dim cmd As New ADODB.Connection, RS As New ADODB.Recordset
cmd.ActiveConnection = connectionString
Debug.Print connectionString
cmd.ActiveConnection.CursorLocation = adUseClient
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "sp_Myproc"
cmd.Parameters.Refresh
cmd(1) = Me.my_id
Set RS = cmd.Execute

'Should be checking if record set is open and explicitly close it. JWS
If RS.State = 1 Then
RS.Close
Set RS = Nothing
End If

cmd.ActiveConnection.Close

I am not able to declare the cmd and RS variables because ADODB doesn't seem to exist. How do I reference this in Access or what is the correct way to accomplish this?

like image 480
John S Avatar asked Apr 03 '14 17:04

John S


People also ask

What reference is needed for Adodb connection?

adodb. We need add 'Microsoft Activex Data Objects Library' from References to reference the ADO in VBA.

How do you add references in Access?

To add a reference to a library: Open the database. Press ALT+F11 to start Visual Basic Editor. On the Tools menu, click References.

How do I add a reference library in VBA?

Add an object library reference to your projectSelect the object library reference in the Available References box in the References dialog box and choose OK. Your Visual Basic project now has a reference to the application's object library.


1 Answers

As I wrote in my comment, you need to check that the ADODB reference is enabled:

  1. On the VBA Editor, clic on the "Tools" menu, and then clic on "References..."
  2. Verify thet the checkmark for "Microsoft ActiveX Data Objects x.x Library" is activated; if it is not, activate it.

Further reference: Using ADO with Microsoft VB & VBA

like image 190
Barranka Avatar answered Sep 18 '22 17:09

Barranka