By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,256 Members | 1,700 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,256 IT Pros & Developers. It's quick & easy.

Data provider could not be initialized error help

P: 1
I am trying to debug a VBA program in Access and have no idea what I am doing, but when I execute the code I get the following error:
"Data provider could not be initialized"

The debugger sends me to the "Set conn = CurrentProject.AccessConnection" in the code below which I searched help for and found that current project is one of the properties in Access 2007 that is blocked by sandbox mode. So I followed the instructions and changed the sandbox number in the registry from 3 to 2, but still the same error. I also made sure to add the file path to the trusted locations. I might be leading down the wrong path altogether, but this works on other machines and not mine making me think it is a security setting.
Anyhow, any help would be much appreciated.

Expand|Select|Wrap|Line Numbers
  1. Dim rs As DAO.Recordset, rs1 As DAO.Recordset
  2. Set rs = CurrentDb.OpenRecordset("SELECT count(litter), litter, pad_name FROM tpl_Efficiency_Output GROUP BY pad_name, litter")
  3. Dim exeStr As String
  4. Dim conn As New ADODB.Connection
  5. Set conn = CurrentProject.AccessConnection
  6.  
  7. Do Until rs.EOF
  8.     If rs(0) <= 2 Then
  9.         If rs(1) > 1 Then
  10.             exeStr = "update tpl_Efficiency_Output set Litter="
  11.             exeStr = exeStr & rs(1) - 1
  12.             exeStr = exeStr & "  where pad_name="
  13.             exeStr = exeStr & "'" & rs(2) & "'"
  14.             exeStr = exeStr & " and Litter=" & rs(1)
  15.             conn.Execute (exeStr)
  16.         End If
  17.     End If
  18.     rs.MoveNext
  19. Loop
  20. rs.Close
  21.  
  22. End Sub
Jul 13 '10 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 636
@JulieV
Hi

Have you tried this instead

Set conn = CurrentProject.Connection

I assume this hasn't changed in Access 2007

??

MTB
Jul 14 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.