Envoyé par
argyronet
Le nom du formulaire n'a aucune importance ici.
Je pense que vous n'avez pas ajouté
le module de classe comme spécifié dans le tuto...
/!\ Avant d’exécuter du code,il faut compiler afin de voir s'il n'y a pas d'erreur.
Argy
Bien sure j'ai ajouté "clsAutoRefresh":
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| Option Compare Database
Option Explicit
'**********************************************************************
' Module : clsAutoRefresh
' Type : Module de classe
' DateTime : 10/10/2009
' Author : Jean-Philippe AMBROSINO
' Purpose : Classe dédiée au rafraîchissement automatique des données
'**********************************************************************
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private m_intTimerInterval As Integer
Private m_strFormCaption As String
' Propriété de valeur du Timer
Public Property Get p_intTimerInterval() As Integer
p_intTimerInterval = m_intTimerInterval
End Property
Public Property Let p_intTimerInterval(ByVal ip_intTimerInterval As Integer)
m_intTimerInterval = ip_intTimerInterval
End Property
' Propriété de la légende du formulaire
Public Property Get p_strFormCaption() As String
p_strFormCaption = m_strFormCaption
End Property
Public Property Let p_strFormCaption(ByVal sp_strFormCaption As String)
m_strFormCaption = sp_strFormCaption
End Property
' Événement DoubleClick du formulaire (Zone grisée)
Public Sub FormDblClick(ByRef TargetForm As Form, Cancel As Integer)
If p_intTimerInterval Then
p_intTimerInterval = 0
TargetForm.Caption = p_strFormCaption & " (Rafraîchissement stoppé : Pressez un double-clic pour le relancer...)"
Else
p_intTimerInterval = 1000
End If
TargetForm.TimerInterval = p_intTimerInterval
End Sub
' Événement Load du formulaire
Public Sub FormOnLoad(ByRef TargetForm As Form)
p_strFormCaption = TargetForm.Caption
TargetForm.TimerInterval = 1000
End Sub
' Événement Timer du formulaire
Public Sub FormOnTimer(ByRef TargetForm As Form, Optional ByVal ResetTime As Integer = 16)
Dim D As Integer
Static S As Integer
If S = ResetTime Then
S = 0: D = 0
TargetForm.Caption = "Rafraîchissement imminent...."
Sleep 1000
DoEvents
TargetForm.Requery
End If
S = S + 1
D = ResetTime - S
DoEvents
TargetForm.Caption = p_strFormCaption & " : Rafraîchissement des données dans " & D & " seconde" & IIf(D <= 1, "", "s")
End Sub |
Ensuite le module du formulaire
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Option Compare Database
Option Explicit
'**********************************************************************
' Module : TBL_ExcelFileData (DataSheetForm)
' Type : Document VBA
' DateTime : 09/10/2009
' Author : Jean-Philippe AMBROSINO
' Purpose : Formulaire contenant les importations temporaires Excel
'**********************************************************************
Private mc_AutoRefresh As clsAutoRefresh
Private Sub Form_Close()
Set mc_AutoRefresh = Nothing
End Sub
Private Sub Form_DblClick(Cancel As Integer)
mc_AutoRefresh.FormDblClick Me, Cancel
End Sub
Private Sub Form_Load()
Set mc_AutoRefresh = New clsAutoRefresh
With mc_AutoRefresh
.p_strTitleCaption = Me.Caption
.p_intTimerInterval = 1000
Me.TimerInterval = .p_intTimerInterval
End With
End Sub
Private Sub Form_Timer()
mc_AutoRefresh.FormOnTimer Me
End Sub |
Puis compilé:
Le message d'erreur survient à partir de cette ligne de code
.p_strTitleCaption = Me.Caption
Cordialement.
Partager