Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sub QueryTable-AfterRefresh, how make it work?

Status
Not open for further replies.

rudo

Programmer
Jul 3, 2002
72
NL
Hi,

I try to use for the first time a vb Excel macro called Private Sub QueryTable_AfterRefresh(Success As Boolean).

The situation: several columns in an Excel-worksheet ("Sheet1") are updated automatically each 10 minutes by a databasequery. I use this method for the first time. This query works fine. Immediately after each query some tasks have to be executed, for which I want to write code in the sub AfterRefresh.

My problem: Despite the "explanations" in vb-help, I do not understand how to make it work. Upto now, in the vb-editor I have created a classmodule, called Klasse1. In this module I have written following lines (which until now do not make any sense to me. LOL):

Public WithEvents qtQueryTable As QueryTable

Private Sub Class_Initialise()
'I don't know if I have to use this and which code
'it should contain.
End Sub

Sub InitQueryEvent(QT As Object)
Set qtQueryTable = QT
End Sub

Private Sub QueryTable-AfterRefresh(Success As Boolean)
If Success Then
Msgbox "Refresh successfully executed"
Else
Msgbox "Refresh failed"
End If
End sub

Can anyone tell me what I have to do to make the sub AfterRefresh work?

Thank you for your help. Greetings,

Rudo (Holland)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top