JKwan
06-20-2014, 11:35 AM
I am trying to run the below code in a vbs file, for whatever the reason I cannot figure out why I am getting the error of "Provider not found"??? If I drop the code into Excel it runs without any problem.
Thanks
Option Explicit
Const gPSIDB = "C:\Temp\PersonalSafety.accdb"
Const adOpenDynamic = 2 ' Will see Addition, Changes or Deletions
Const adLockReadOnly = 1
Const adOpenStatic = 3 ' Will not see Addition, Changes or Deletions
Const adModeRead = 1
Const adModeWrite = 2
Dim objTemp
Dim sSQL
Dim objConnection
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open _
"Provider = Microsoft.ACE.OLEDB.12.0; " & _
"Data Source = '" & gPSIDB & "'"
Set objTemp = CreateObject("ADODB.Recordset")
sSQL = "Select [CaseNumber] " & _
"From PersonalSafety Order By [CaseNumber]"
objTemp.Open sSQL, objConnection, adOpenStatic, adLockReadOnly
objTemp.MoveLast
Msgbox CStr(objTemp.Fields("CaseNumber").Value + 1)
Set objTemp = Nothing
Set objParent = Nothing
Thanks
Option Explicit
Const gPSIDB = "C:\Temp\PersonalSafety.accdb"
Const adOpenDynamic = 2 ' Will see Addition, Changes or Deletions
Const adLockReadOnly = 1
Const adOpenStatic = 3 ' Will not see Addition, Changes or Deletions
Const adModeRead = 1
Const adModeWrite = 2
Dim objTemp
Dim sSQL
Dim objConnection
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open _
"Provider = Microsoft.ACE.OLEDB.12.0; " & _
"Data Source = '" & gPSIDB & "'"
Set objTemp = CreateObject("ADODB.Recordset")
sSQL = "Select [CaseNumber] " & _
"From PersonalSafety Order By [CaseNumber]"
objTemp.Open sSQL, objConnection, adOpenStatic, adLockReadOnly
objTemp.MoveLast
Msgbox CStr(objTemp.Fields("CaseNumber").Value + 1)
Set objTemp = Nothing
Set objParent = Nothing