[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Re: problem with "Refresh BackgroundQuery=False"

NickHK

12/12/2006 3:20:00 AM

The problem may be nothing to do with Excel (hence the generic 1004 error),
but one of the data access layers used to retrive the data. There are 2
error collections associated with data accesss that may be populated
depending on provider etc. See if you get anything useful.

Private Sub CommandButton2_Click()

On Error GoTo Handler

'Change to the name/location of your querytable
ActiveSheet.QueryTables("QT1").Refresh BackgroundQuery:=False

Exit Sub

Handler:
Dim Msg As String
Dim i As Long

Select Case Err.Number
Case 1004
With Application.ODBCErrors
Msg = "ODBC Errors :" & vbNewLine
For i = 1 To .Count
Msg = Msg & .Item(i).ErrorString & vbNewLine
Next
End With

With Application.OLEDBErrors
Msg = Msg & "OLEDB Errors :" & vbNewLine
For i = 1 To .Count
'More info available on OLEDB error if required
Msg = Msg & .Item(i).ErrorString & vbNewLine
Next
End With

Case Else
Msg = "Error Number: " & Err.Number & vbNewLine & Err.Description
End Select

MsgBox Msg

End Sub



"Johnson" <Johnson@discussions.microsoft.com> wrote in message
news:15EEE8F8-73AD-48A7-A7DB-ECDAC1E4B5F3@microsoft.com...
> Hi,
> I just want to know if there's error ending up at the code "Refresh
> BackgroundQuery=False" and given the error message e.g. error code 1004.
> My question's are;
> 1. What's the reason behined
> 2. How to fix it.
>
> --
> Johnosn