Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default run-time error '1004' general odbc error

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default run-time error '1004' general odbc error

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



"Jeff Gross" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default run-time error '1004' general odbc error

Line 32 is :

qt.Refresh BackgroundQuery:=False


"JLGWhiz" wrote:

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



"Jeff Gross" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Run Time Error '1004' General ODBC Error CLR Excel Programming 6 September 16th 10 11:14 PM
Run-time error 1004 - General ODBC Error Linda Excel Programming 0 July 5th 06 04:32 PM
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
Runtime error '1004' General ODBC error star_lucas New Users to Excel 0 August 29th 05 04:09 PM


All times are GMT +1. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"