run-time error '1004' general odbc error

J

Jeff Gross

I added a query by doing a cut/paste and changing the items to retrieve, but
now when i run my code, i get a run-time error and the debug takes me to line
32.

My code is as follows:

Sub Main()
Dim qt As QueryTable, qtc As QueryTable
Dim Counter As Double, qtcnt As Double, qttotal As Double
Dim RowMax As Integer, ColMax As Integer
Dim r As Integer, c As Integer
Dim PctDone As Single

Application.ScreenUpdating = False
Application.DisplayStatusBar = False
'Initialize variables.
Counter = 1
qtcnt = 1
RowMax = 100
ColMax = 25
For Each qtc In ActiveSheet.QueryTables
qtcnt = qtcnt + 1
Next qtc
qttotal = qtcnt
qtcnt = 0
cnt = 1
'Loop through cells.
'For r = 1 To RowMax
'For Each qt In ActiveSheet.QueryTables
'For qt = 1 To qttotal
'For c = 1 To ColMax
'Put a random number in a cell
'Cells(r, c) = Int(Rnd * 1000)
'For Counter = 1 To 10000000
'Next Counter
Counter = Counter + 1
For Each qt In ActiveSheet.QueryTables
qt.Refresh BackgroundQuery:=False

'Next qt
'Next c
'Update the percentage completed.
'PctDone = Counter / (RowMax * ColMax)
PctDone = qtcnt
'qt.Refresh BackgroundQuery:=False
qtcnt = qtcnt + ((100 / qttotal) / 100)
cnt = cnt + 1
'sqtname = qt.Name
'Call subroutine that updates the progress bar.
UpdateProgressBar PctDone
Next qt
'Next r

'The task is finished, so unload the UserForm.
Call AllWorksheetPivots
Unload Userform1
Application.DisplayStatusBar = True

End Sub

Once I get to 20% complete or 77% complete, it crashes at the query refresh
at line 32.

Any help would be appreciated.

Jeff
 
J

JLGWhiz

Since you have several lines commented out, would you like to describe what
line 32 looks like?
 
J

Jeff Gross

Line 32 is :

qt.Refresh BackgroundQuery:=False


JLGWhiz said:
Since you have several lines commented out, would you like to describe what
line 32 looks like?
 

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

Top