Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access connection problem in vba 7.0

Status
Not open for further replies.

packmen

Mechanical
Aug 31, 2001
77
0
0
BR
Hi all.

I'm upgrading to solidworks 2014 but I must connect to a Access file first and I'm getting a "Provider not found" error '3706' in the last line of the code.

I needed to add PtrSafe in the code so the rest is working, but the code below aren't.
I change the Provider=Microsoft.Jet.OLEDB.4.0 to Provider=Microsoft.Jet.OLEDB.12.0 and my Office's version is 14.0.7015.1000 (64 bits). I also added the "Microsoft Access 14.0 Object Library" reference in vba 7
Code:
Function GetNewDBCode(sName As String, sOldCode As String, sMachineName As String) As String

    Dim sReturn As String
    Dim sOldName As String
    
'Define the three objects that we need,
  '   A Connection Object - connects to our data source
  '   A Command Object - defines what data to get from the data source
  '   A RecordSet Object - stores the data we get from our data source

  Dim conConnection As New ADODB.Connection
  Dim cmdCommand As New ADODB.Command
  Dim rstRecordSet As New ADODB.Recordset

  'Defines the connection string for the Connection.  Here we have used fields
  'Provider, Data Source and Mode to assign values to the properties
  ' conConnection.Provider and conConnection.Mode

  conConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.12.0;Data Source=" & "X:\CADASTRO DE MATERIAIS.mdb;Mode=Read|Write"

  'Define the location of the cursor engine, in this case we are opening an Access database
  'and adUseClient is our only choice.

  conConnection.CursorLocation = adUseClient

  'Opens our connection using the password "Admin" to access the database.  If there was no password
  'protection on the database this field could be left out.

  conConnection.Open

can't someone point me the right direction?

thanks

Emerson BB
 
Replies continue below

Recommended for you

Your best bet is unfortunately to get away from .mdb and migrate your data to SQL Server or something like that. It's what I ended up having to do. Supposedly, if you really have 64 bit office installed (it's pretty rare), you should be able to get it to work.

-handleman, CSWP (The new, easy test)
 
I Made it work, I just replace the Jet to ACE in the provider and it work! :D
I don't know how i can make it useful and easy to find but I had a real headache trying to make it work.
 
Status
Not open for further replies.
Back
Top