Code execution has been interrupted

  • Thread starter Thread starter ryan.fitzpatrick3
  • Start date Start date
R

ryan.fitzpatrick3

What does Code execution has been interrupted mean.

Here is my code.

Sub Access_Data()

' Access_Query

Dim conn As New ADODB.Connection
Dim rst As ADODB.Recordset
Dim strPath As String

strPath = "C:\Documents and Settings\rfitz03\Desktop\RYAN'S EXCEL
SHEETS\Strategic Sourcing\Forms\Position Sheet\flour.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:="MonthlyReceivings", _
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 ( <-----------------)
Problem with code here.
End With
rst.Close
conn.Close
End Sub



This code has worked great in the past, except when I changed the
access table to another table it now doesn't want to work. Can someone
help?

Ryan
 
It gets mad because you changed without telling it you were going to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top