I am trying to automate updates in a workbook that I am creating by pulling a table from another workbook.
I was given the following code to start with:
Sub EXCEL_DATA_GRAB()
Dim cnt As ADODB.Connection
Dim rst As ADODB.Recordset
Dim rstKey As ADODB.Recordset
Dim strQry As String
Dim strQryKey As String
' Dim rngPop As Variant
'
' Set rngPop = ThisWorkbook.Sheets("GetData").Range("_Population")
'//Build connection string
strConProvider = "Provider=Microsoft.ACE.OLEDB.12.0;"
strConSource = "Data Source=" & " J:\STOP LOSS\jpo\ultimatePA\" & Sheet4!A6 & "\" & Sheet4!A6 & "-" & Z6 & "\SNAP_SHOT-" & Sheet4!A6 & "-" & Sheet4!B6 & "-" & Sheet4!C6 & ".xlsm;" strConExtProp = "Extended Properties=Excel 12.0;"
strConSecurity = "Persist Security Info=False"
strCon = strConProvider & strConSource & strConExtProp & strConSecurity
End Sub
But when I look at the connection detail from manually connecting the two I get a lot more information:
Provider=Microsoft.ACE.OLEDB.12.0;
User ID = Admin
Data Source=J:\STOP LOSS\jpo\ultimatePA\2011\2011-03\SNAP_SHOT-2011-MAR-31.xlsm;
Mode=Share Deny Write;
Extended Properties="HDR=YES;";
Jet OLEDB:System database="";
Jet OLEDB:Registry Path="";
Jet OLEDB:Engine Type=37;
Jet OLEDB:Database Locking Mode=0;
Jet OLEDB:Global Partial Bulk Ops=2;
Jet OLEDB:Global Bulk Transactions=1;
Jet OLEDB:New Database Password="";
Jet OLEDB:Create System Database=False;
Jet OLEDB:Encrypt Database=False;
Jet OLEDB: Dont Copy Locale on Compact=False;
Jet OLEDB:Compact Without Replica Repair=False;
Jet OLEDB:SFP=False;
Jet OLEDB:Support Complex Data=False
The data source in the manual connection has not been edited for the variables. That is why it looks different. What I am doing is having the user select the date from 3 validation drop downs to form the needed date for the data pull.
I am lost at what information I need from the manual connection that I located in order for it to work in vba. I am pulling the information from lets say DataSheet.
Any help would be greatly appreciated.
Thank you
Dave
I was given the following code to start with:
Sub EXCEL_DATA_GRAB()
Dim cnt As ADODB.Connection
Dim rst As ADODB.Recordset
Dim rstKey As ADODB.Recordset
Dim strQry As String
Dim strQryKey As String
' Dim rngPop As Variant
'
' Set rngPop = ThisWorkbook.Sheets("GetData").Range("_Population")
'//Build connection string
strConProvider = "Provider=Microsoft.ACE.OLEDB.12.0;"
strConSource = "Data Source=" & " J:\STOP LOSS\jpo\ultimatePA\" & Sheet4!A6 & "\" & Sheet4!A6 & "-" & Z6 & "\SNAP_SHOT-" & Sheet4!A6 & "-" & Sheet4!B6 & "-" & Sheet4!C6 & ".xlsm;" strConExtProp = "Extended Properties=Excel 12.0;"
strConSecurity = "Persist Security Info=False"
strCon = strConProvider & strConSource & strConExtProp & strConSecurity
End Sub
But when I look at the connection detail from manually connecting the two I get a lot more information:
Provider=Microsoft.ACE.OLEDB.12.0;
User ID = Admin
Data Source=J:\STOP LOSS\jpo\ultimatePA\2011\2011-03\SNAP_SHOT-2011-MAR-31.xlsm;
Mode=Share Deny Write;
Extended Properties="HDR=YES;";
Jet OLEDB:System database="";
Jet OLEDB:Registry Path="";
Jet OLEDB:Engine Type=37;
Jet OLEDB:Database Locking Mode=0;
Jet OLEDB:Global Partial Bulk Ops=2;
Jet OLEDB:Global Bulk Transactions=1;
Jet OLEDB:New Database Password="";
Jet OLEDB:Create System Database=False;
Jet OLEDB:Encrypt Database=False;
Jet OLEDB: Dont Copy Locale on Compact=False;
Jet OLEDB:Compact Without Replica Repair=False;
Jet OLEDB:SFP=False;
Jet OLEDB:Support Complex Data=False
The data source in the manual connection has not been edited for the variables. That is why it looks different. What I am doing is having the user select the date from 3 validation drop downs to form the needed date for the data pull.
I am lost at what information I need from the manual connection that I located in order for it to work in vba. I am pulling the information from lets say DataSheet.
Any help would be greatly appreciated.
Thank you
Dave