Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
run time error 1004 general odbc error excel 2003 vba | Excel Programming | |||
Run Time Error '1004' General ODBC Error | Excel Programming | |||
Run-time error 1004 - General ODBC Error | Excel Programming | |||
Run time error 1004, General ODBC error | New Users to Excel | |||
Runtime error '1004' General ODBC error | New Users to Excel |