R
ryan.fitzpatrick3
This used to work perfectly all the time and now I get adUseClient
error? Can someone help me real quick, and if I need to change this
where abouts do i change this at? Thank you.
Dim conn As New ADODB.Connection
Dim rst As ADODB.Recordset
Dim strPath As String
strPath = "C:\Documents and Settings\rfitz03\Desktop\Ryan's
Practice Database.mdb"
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strPath & ";"
conn.CursorLocation = adUseClient
' Create a Recordset from all the records
' in the Products table
Set rst = conn.Execute(CommandText:="SupplyPlantFlourtbl", _
Options:=adCmdTable)
' begin with the first record
rst.MoveFirst
' transfer the data to Excel
' get the names of fields first
With Worksheets("Pulled from Access").Range("A6")
.CurrentRegion.Clear
For j = 0 To rst.Fields.Count - 1
.Offset(0, j) = rst.Fields(j).Name
Next j
.Offset(1, 0).CopyFromRecordset rst
' .Offset(1, 0).CopyFromRecordset rst, 5
' .Offset(1, 0).CopyFromRecordset rst, , 2
.CurrentRegion.Columns.AutoFit
End With
rst.Close
conn.Close
End Sub
ryan
error? Can someone help me real quick, and if I need to change this
where abouts do i change this at? Thank you.
Dim conn As New ADODB.Connection
Dim rst As ADODB.Recordset
Dim strPath As String
strPath = "C:\Documents and Settings\rfitz03\Desktop\Ryan's
Practice Database.mdb"
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strPath & ";"
conn.CursorLocation = adUseClient
' Create a Recordset from all the records
' in the Products table
Set rst = conn.Execute(CommandText:="SupplyPlantFlourtbl", _
Options:=adCmdTable)
' begin with the first record
rst.MoveFirst
' transfer the data to Excel
' get the names of fields first
With Worksheets("Pulled from Access").Range("A6")
.CurrentRegion.Clear
For j = 0 To rst.Fields.Count - 1
.Offset(0, j) = rst.Fields(j).Name
Next j
.Offset(1, 0).CopyFromRecordset rst
' .Offset(1, 0).CopyFromRecordset rst, 5
' .Offset(1, 0).CopyFromRecordset rst, , 2
.CurrentRegion.Columns.AutoFit
End With
rst.Close
conn.Close
End Sub
ryan