Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryD ate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues e t
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryD ate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues e t
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryD ate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues e t
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
Petite précision :
Si j'enlève du code la partie suivante tout fonctionne sans
problèmes :
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
Normalement on est pas sensés libérer les variables/objets une fois
qu'on a plus besoin ?
On 27 mar, 17:23, seliana wrote:Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues et
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
Petite précision :
Si j'enlève du code la partie suivante tout fonctionne sans
problèmes :
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
Normalement on est pas sensés libérer les variables/objets une fois
qu'on a plus besoin ?
On 27 mar, 17:23, seliana <altarbo...@gmail.com> wrote:
Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues et
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
Petite précision :
Si j'enlève du code la partie suivante tout fonctionne sans
problèmes :
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
Normalement on est pas sensés libérer les variables/objets une fois
qu'on a plus besoin ?
On 27 mar, 17:23, seliana wrote:Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues et
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
bonjour,
essai en y ajoutant une boucle :
While état1 = adStateClose
état1 = rstRecordset.State
Wend
While état2 = adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
> Petite précision :
> Si j'enlève du code la partie suivante tout fonctionne sans
> problèmes :
> 'libere objets
> Set cnnConn = Nothing
> Set rstRecordset = Nothing
> Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
> Normalement on est pas sensés libérer les variables/objets une fois
> qu'on a plus besoin ?
> On 27 mar, 17:23, seliana wrote:
>> Bonjour microsoft.public.fr.excel,
>> Comment se fait il que le code ci dessous fasse crasher Excel quand
>> exécuté sans interruption alors que s'il est exécuté pas à p as tout
>> fonctionne sans problème.
>> j'ai sur ma feuille :
>> calAgent - objet calendrier (microsoft calendar control 11.0)
>> VSFlexGrid1 - voila :) VS Flex Grid v7
>> ComboBox1 - objet combobox
>> ainsi que un bouton (CommandButton1) et quelques textbox et label mais
>> qui ne sont pas encore utilisés
>> Voici le code en question.
>> --------------------------------------------
>> Option Explicit
>> 'declaration de variables
>> Dim cnnConn As ADODB.Connection
>> Dim rstRecordset As ADODB.recordSet
>> Dim tempQuery As String
>> Private Sub CommandButton1_Click()
>> 'definition de variables
>> Set cnnConn = New ADODB.Connection
>> Set rstRecordset = New ADODB.recordSet
>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
>> tAgents.percentage, tBEELoginLogout.entryDate,
>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.ent ryDate)
>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
>> "#));"
>> 'Vérifie que la connexion est bien fermée
>> If cnnConn.State = adStateOpen Then cnnConn.Close
>> 'Etabli la connection
>> cnnConn.ConnectionString = CAppConnectionString
>> cnnConn.Open CAppPathTodB
>> 'Attente que la connexion soit établie
>> While (cnnConn.State = adStateConnecting)
>> DoEvents
>> Wend
>> 'vérifie que le recordset est bien fermée
>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>> 'ouvre le recordset
>> rstRecordset.Open tempQuery, cnnConn
>> 'transpose recordset dans grid
>> Set VSFlexGrid1.DataSource = rstRecordset
>> 'si recordset encore ouvert alors le ferme
>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>> 'si connection encore ouverte alors la ferme
>> If cnnConn.State = adStateOpen Then cnnConn.Close
>> 'libere objets
>> Set cnnConn = Nothing
>> Set rstRecordset = Nothing
>> End Sub
>> --------------------------------------------
>> ainsi que quelques constantes définies dans un module
>> --------------------------------------------
>> Public Const AppVersion = "0.2.9"
>> Public Const AppInDevMode = True
>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
>> Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
>> 4.0;"
>> --------------------------------------------
>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
>> nickel sans problémes les données de la base de données sont lue s et
>> affichés dans le grid.
>> mais si je n'ai pas de point d'arret, tout le code est executé et a la
>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
>> d'aprés quelques debug.print que j'ai mis)
>> Quelqu'un saurait pourquoi ?
bonjour,
essai en y ajoutant une boucle :
While état1 = adStateClose
état1 = rstRecordset.State
Wend
While état2 = adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
> Petite précision :
> Si j'enlève du code la partie suivante tout fonctionne sans
> problèmes :
> 'libere objets
> Set cnnConn = Nothing
> Set rstRecordset = Nothing
> Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
> Normalement on est pas sensés libérer les variables/objets une fois
> qu'on a plus besoin ?
> On 27 mar, 17:23, seliana <altarbo...@gmail.com> wrote:
>> Bonjour microsoft.public.fr.excel,
>> Comment se fait il que le code ci dessous fasse crasher Excel quand
>> exécuté sans interruption alors que s'il est exécuté pas à p as tout
>> fonctionne sans problème.
>> j'ai sur ma feuille :
>> calAgent - objet calendrier (microsoft calendar control 11.0)
>> VSFlexGrid1 - voila :) VS Flex Grid v7
>> ComboBox1 - objet combobox
>> ainsi que un bouton (CommandButton1) et quelques textbox et label mais
>> qui ne sont pas encore utilisés
>> Voici le code en question.
>> --------------------------------------------
>> Option Explicit
>> 'declaration de variables
>> Dim cnnConn As ADODB.Connection
>> Dim rstRecordset As ADODB.recordSet
>> Dim tempQuery As String
>> Private Sub CommandButton1_Click()
>> 'definition de variables
>> Set cnnConn = New ADODB.Connection
>> Set rstRecordset = New ADODB.recordSet
>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
>> tAgents.percentage, tBEELoginLogout.entryDate,
>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.ent ryDate)
>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
>> "#));"
>> 'Vérifie que la connexion est bien fermée
>> If cnnConn.State = adStateOpen Then cnnConn.Close
>> 'Etabli la connection
>> cnnConn.ConnectionString = CAppConnectionString
>> cnnConn.Open CAppPathTodB
>> 'Attente que la connexion soit établie
>> While (cnnConn.State = adStateConnecting)
>> DoEvents
>> Wend
>> 'vérifie que le recordset est bien fermée
>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>> 'ouvre le recordset
>> rstRecordset.Open tempQuery, cnnConn
>> 'transpose recordset dans grid
>> Set VSFlexGrid1.DataSource = rstRecordset
>> 'si recordset encore ouvert alors le ferme
>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>> 'si connection encore ouverte alors la ferme
>> If cnnConn.State = adStateOpen Then cnnConn.Close
>> 'libere objets
>> Set cnnConn = Nothing
>> Set rstRecordset = Nothing
>> End Sub
>> --------------------------------------------
>> ainsi que quelques constantes définies dans un module
>> --------------------------------------------
>> Public Const AppVersion = "0.2.9"
>> Public Const AppInDevMode = True
>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
>> Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
>> 4.0;"
>> --------------------------------------------
>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
>> nickel sans problémes les données de la base de données sont lue s et
>> affichés dans le grid.
>> mais si je n'ai pas de point d'arret, tout le code est executé et a la
>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
>> d'aprés quelques debug.print que j'ai mis)
>> Quelqu'un saurait pourquoi ?
bonjour,
essai en y ajoutant une boucle :
While état1 = adStateClose
état1 = rstRecordset.State
Wend
While état2 = adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
> Petite précision :
> Si j'enlève du code la partie suivante tout fonctionne sans
> problèmes :
> 'libere objets
> Set cnnConn = Nothing
> Set rstRecordset = Nothing
> Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
> Normalement on est pas sensés libérer les variables/objets une fois
> qu'on a plus besoin ?
> On 27 mar, 17:23, seliana wrote:
>> Bonjour microsoft.public.fr.excel,
>> Comment se fait il que le code ci dessous fasse crasher Excel quand
>> exécuté sans interruption alors que s'il est exécuté pas à p as tout
>> fonctionne sans problème.
>> j'ai sur ma feuille :
>> calAgent - objet calendrier (microsoft calendar control 11.0)
>> VSFlexGrid1 - voila :) VS Flex Grid v7
>> ComboBox1 - objet combobox
>> ainsi que un bouton (CommandButton1) et quelques textbox et label mais
>> qui ne sont pas encore utilisés
>> Voici le code en question.
>> --------------------------------------------
>> Option Explicit
>> 'declaration de variables
>> Dim cnnConn As ADODB.Connection
>> Dim rstRecordset As ADODB.recordSet
>> Dim tempQuery As String
>> Private Sub CommandButton1_Click()
>> 'definition de variables
>> Set cnnConn = New ADODB.Connection
>> Set rstRecordset = New ADODB.recordSet
>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
>> tAgents.percentage, tBEELoginLogout.entryDate,
>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.ent ryDate)
>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
>> "#));"
>> 'Vérifie que la connexion est bien fermée
>> If cnnConn.State = adStateOpen Then cnnConn.Close
>> 'Etabli la connection
>> cnnConn.ConnectionString = CAppConnectionString
>> cnnConn.Open CAppPathTodB
>> 'Attente que la connexion soit établie
>> While (cnnConn.State = adStateConnecting)
>> DoEvents
>> Wend
>> 'vérifie que le recordset est bien fermée
>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>> 'ouvre le recordset
>> rstRecordset.Open tempQuery, cnnConn
>> 'transpose recordset dans grid
>> Set VSFlexGrid1.DataSource = rstRecordset
>> 'si recordset encore ouvert alors le ferme
>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>> 'si connection encore ouverte alors la ferme
>> If cnnConn.State = adStateOpen Then cnnConn.Close
>> 'libere objets
>> Set cnnConn = Nothing
>> Set rstRecordset = Nothing
>> End Sub
>> --------------------------------------------
>> ainsi que quelques constantes définies dans un module
>> --------------------------------------------
>> Public Const AppVersion = "0.2.9"
>> Public Const AppInDevMode = True
>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
>> Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
>> 4.0;"
>> --------------------------------------------
>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
>> nickel sans problémes les données de la base de données sont lue s et
>> affichés dans le grid.
>> mais si je n'ai pas de point d'arret, tout le code est executé et a la
>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
>> d'aprés quelques debug.print que j'ai mis)
>> Quelqu'un saurait pourquoi ?
Salut Isabelle,
Je ne vois pas trop ou mettre ces deux boucles.
On 27 mar, 19:17, isabelle wrote:bonjour,
essai en y ajoutant une boucle :
While état1 = adStateClose
état1 = rstRecordset.State
Wend
While état2 = adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :Petite précision :
Si j'enlève du code la partie suivante tout fonctionne sans
problèmes :
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
Normalement on est pas sensés libérer les variables/objets une fois
qu'on a plus besoin ?
On 27 mar, 17:23, seliana wrote:Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues et
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
Salut Isabelle,
Je ne vois pas trop ou mettre ces deux boucles.
On 27 mar, 19:17, isabelle <i@v> wrote:
bonjour,
essai en y ajoutant une boucle :
While état1 = adStateClose
état1 = rstRecordset.State
Wend
While état2 = adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
Petite précision :
Si j'enlève du code la partie suivante tout fonctionne sans
problèmes :
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
Normalement on est pas sensés libérer les variables/objets une fois
qu'on a plus besoin ?
On 27 mar, 17:23, seliana <altarbo...@gmail.com> wrote:
Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues et
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
Salut Isabelle,
Je ne vois pas trop ou mettre ces deux boucles.
On 27 mar, 19:17, isabelle wrote:bonjour,
essai en y ajoutant une boucle :
While état1 = adStateClose
état1 = rstRecordset.State
Wend
While état2 = adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :Petite précision :
Si j'enlève du code la partie suivante tout fonctionne sans
problèmes :
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
Normalement on est pas sensés libérer les variables/objets une fois
qu'on a plus besoin ?
On 27 mar, 17:23, seliana wrote:Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues et
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
>> While état1 = adStateClosed
>> état1 = rstRecordset.State
>> Wend
>> While état2 = adStateClosed
>> état2 = cnnConn.State
>> Wend
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Salut altarboy,
juste avant
Set cnnConn = Nothing
Set rstRecordset = Nothing
isabelle
altarboy a écrit :
> Salut Isabelle,
> Je ne vois pas trop ou mettre ces deux boucles.
> On 27 mar, 19:17, isabelle wrote:
>> bonjour,
>> essai en y ajoutant une boucle :
>> While état1 = adStateClose
>> état1 = rstRecordset.State
>> Wend
>> While état2 = adStateClose
>> état2 = cnnConn.State
>> Wend
>> isabelle
>> altarboy a écrit :
>>> Petite précision :
>>> Si j'enlève du code la partie suivante tout fonctionne sans
>>> problèmes :
>>> 'libere objets
>>> Set cnnConn = Nothing
>>> Set rstRecordset = Nothing
>>> Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
>>> Normalement on est pas sensés libérer les variables/objets une fo is
>>> qu'on a plus besoin ?
>>> On 27 mar, 17:23, seliana wrote:
>>>> Bonjour microsoft.public.fr.excel,
>>>> Comment se fait il que le code ci dessous fasse crasher Excel quand
>>>> exécuté sans interruption alors que s'il est exécuté pas à pas tout
>>>> fonctionne sans problème.
>>>> j'ai sur ma feuille :
>>>> calAgent - objet calendrier (microsoft calendar control 11.0)
>>>> VSFlexGrid1 - voila :) VS Flex Grid v7
>>>> ComboBox1 - objet combobox
>>>> ainsi que un bouton (CommandButton1) et quelques textbox et label ma is
>>>> qui ne sont pas encore utilisés
>>>> Voici le code en question.
>>>> --------------------------------------------
>>>> Option Explicit
>>>> 'declaration de variables
>>>> Dim cnnConn As ADODB.Connection
>>>> Dim rstRecordset As ADODB.recordSet
>>>> Dim tempQuery As String
>>>> Private Sub CommandButton1_Click()
>>>> 'definition de variables
>>>> Set cnnConn = New ADODB.Connection
>>>> Set rstRecordset = New ADODB.recordSet
>>>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
>>>> tAgents.percentage, tBEELoginLogout.entryDate,
>>>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
>>>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
>>>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
>>>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
>>>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.e ntryDate)
>>>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
>>>> "#));"
>>>> 'Vérifie que la connexion est bien fermée
>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>> 'Etabli la connection
>>>> cnnConn.ConnectionString = CAppConnectionString
>>>> cnnConn.Open CAppPathTodB
>>>> 'Attente que la connexion soit établie
>>>> While (cnnConn.State = adStateConnecting)
>>>> DoEvents
>>>> Wend
>>>> 'vérifie que le recordset est bien fermée
>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Clos e
>>>> 'ouvre le recordset
>>>> rstRecordset.Open tempQuery, cnnConn
>>>> 'transpose recordset dans grid
>>>> Set VSFlexGrid1.DataSource = rstRecordset
>>>> 'si recordset encore ouvert alors le ferme
>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Clos e
>>>> 'si connection encore ouverte alors la ferme
>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>> 'libere objets
>>>> Set cnnConn = Nothing
>>>> Set rstRecordset = Nothing
>>>> End Sub
>>>> --------------------------------------------
>>>> ainsi que quelques constantes définies dans un module
>>>> --------------------------------------------
>>>> Public Const AppVersion = "0.2.9"
>>>> Public Const AppInDevMode = True
>>>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
>>>> Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLED B.
>>>> 4.0;"
>>>> --------------------------------------------
>>>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
>>>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
>>>> nickel sans problémes les données de la base de données sont l ues et
>>>> affichés dans le grid.
>>>> mais si je n'ai pas de point d'arret, tout le code est executé et a la
>>>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
>>>> d'aprés quelques debug.print que j'ai mis)
>>>> Quelqu'un saurait pourquoi ?
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
>> While état1 = adStateClosed
>> état1 = rstRecordset.State
>> Wend
>> While état2 = adStateClosed
>> état2 = cnnConn.State
>> Wend
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Salut altarboy,
juste avant
Set cnnConn = Nothing
Set rstRecordset = Nothing
isabelle
altarboy a écrit :
> Salut Isabelle,
> Je ne vois pas trop ou mettre ces deux boucles.
> On 27 mar, 19:17, isabelle <i@v> wrote:
>> bonjour,
>> essai en y ajoutant une boucle :
>> While état1 = adStateClose
>> état1 = rstRecordset.State
>> Wend
>> While état2 = adStateClose
>> état2 = cnnConn.State
>> Wend
>> isabelle
>> altarboy a écrit :
>>> Petite précision :
>>> Si j'enlève du code la partie suivante tout fonctionne sans
>>> problèmes :
>>> 'libere objets
>>> Set cnnConn = Nothing
>>> Set rstRecordset = Nothing
>>> Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
>>> Normalement on est pas sensés libérer les variables/objets une fo is
>>> qu'on a plus besoin ?
>>> On 27 mar, 17:23, seliana <altarbo...@gmail.com> wrote:
>>>> Bonjour microsoft.public.fr.excel,
>>>> Comment se fait il que le code ci dessous fasse crasher Excel quand
>>>> exécuté sans interruption alors que s'il est exécuté pas à pas tout
>>>> fonctionne sans problème.
>>>> j'ai sur ma feuille :
>>>> calAgent - objet calendrier (microsoft calendar control 11.0)
>>>> VSFlexGrid1 - voila :) VS Flex Grid v7
>>>> ComboBox1 - objet combobox
>>>> ainsi que un bouton (CommandButton1) et quelques textbox et label ma is
>>>> qui ne sont pas encore utilisés
>>>> Voici le code en question.
>>>> --------------------------------------------
>>>> Option Explicit
>>>> 'declaration de variables
>>>> Dim cnnConn As ADODB.Connection
>>>> Dim rstRecordset As ADODB.recordSet
>>>> Dim tempQuery As String
>>>> Private Sub CommandButton1_Click()
>>>> 'definition de variables
>>>> Set cnnConn = New ADODB.Connection
>>>> Set rstRecordset = New ADODB.recordSet
>>>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
>>>> tAgents.percentage, tBEELoginLogout.entryDate,
>>>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
>>>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
>>>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
>>>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
>>>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.e ntryDate)
>>>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
>>>> "#));"
>>>> 'Vérifie que la connexion est bien fermée
>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>> 'Etabli la connection
>>>> cnnConn.ConnectionString = CAppConnectionString
>>>> cnnConn.Open CAppPathTodB
>>>> 'Attente que la connexion soit établie
>>>> While (cnnConn.State = adStateConnecting)
>>>> DoEvents
>>>> Wend
>>>> 'vérifie que le recordset est bien fermée
>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Clos e
>>>> 'ouvre le recordset
>>>> rstRecordset.Open tempQuery, cnnConn
>>>> 'transpose recordset dans grid
>>>> Set VSFlexGrid1.DataSource = rstRecordset
>>>> 'si recordset encore ouvert alors le ferme
>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Clos e
>>>> 'si connection encore ouverte alors la ferme
>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>> 'libere objets
>>>> Set cnnConn = Nothing
>>>> Set rstRecordset = Nothing
>>>> End Sub
>>>> --------------------------------------------
>>>> ainsi que quelques constantes définies dans un module
>>>> --------------------------------------------
>>>> Public Const AppVersion = "0.2.9"
>>>> Public Const AppInDevMode = True
>>>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
>>>> Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLED B.
>>>> 4.0;"
>>>> --------------------------------------------
>>>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
>>>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
>>>> nickel sans problémes les données de la base de données sont l ues et
>>>> affichés dans le grid.
>>>> mais si je n'ai pas de point d'arret, tout le code est executé et a la
>>>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
>>>> d'aprés quelques debug.print que j'ai mis)
>>>> Quelqu'un saurait pourquoi ?
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
>> While état1 = adStateClosed
>> état1 = rstRecordset.State
>> Wend
>> While état2 = adStateClosed
>> état2 = cnnConn.State
>> Wend
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Salut altarboy,
juste avant
Set cnnConn = Nothing
Set rstRecordset = Nothing
isabelle
altarboy a écrit :
> Salut Isabelle,
> Je ne vois pas trop ou mettre ces deux boucles.
> On 27 mar, 19:17, isabelle wrote:
>> bonjour,
>> essai en y ajoutant une boucle :
>> While état1 = adStateClose
>> état1 = rstRecordset.State
>> Wend
>> While état2 = adStateClose
>> état2 = cnnConn.State
>> Wend
>> isabelle
>> altarboy a écrit :
>>> Petite précision :
>>> Si j'enlève du code la partie suivante tout fonctionne sans
>>> problèmes :
>>> 'libere objets
>>> Set cnnConn = Nothing
>>> Set rstRecordset = Nothing
>>> Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
>>> Normalement on est pas sensés libérer les variables/objets une fo is
>>> qu'on a plus besoin ?
>>> On 27 mar, 17:23, seliana wrote:
>>>> Bonjour microsoft.public.fr.excel,
>>>> Comment se fait il que le code ci dessous fasse crasher Excel quand
>>>> exécuté sans interruption alors que s'il est exécuté pas à pas tout
>>>> fonctionne sans problème.
>>>> j'ai sur ma feuille :
>>>> calAgent - objet calendrier (microsoft calendar control 11.0)
>>>> VSFlexGrid1 - voila :) VS Flex Grid v7
>>>> ComboBox1 - objet combobox
>>>> ainsi que un bouton (CommandButton1) et quelques textbox et label ma is
>>>> qui ne sont pas encore utilisés
>>>> Voici le code en question.
>>>> --------------------------------------------
>>>> Option Explicit
>>>> 'declaration de variables
>>>> Dim cnnConn As ADODB.Connection
>>>> Dim rstRecordset As ADODB.recordSet
>>>> Dim tempQuery As String
>>>> Private Sub CommandButton1_Click()
>>>> 'definition de variables
>>>> Set cnnConn = New ADODB.Connection
>>>> Set rstRecordset = New ADODB.recordSet
>>>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
>>>> tAgents.percentage, tBEELoginLogout.entryDate,
>>>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
>>>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
>>>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
>>>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
>>>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.e ntryDate)
>>>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
>>>> "#));"
>>>> 'Vérifie que la connexion est bien fermée
>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>> 'Etabli la connection
>>>> cnnConn.ConnectionString = CAppConnectionString
>>>> cnnConn.Open CAppPathTodB
>>>> 'Attente que la connexion soit établie
>>>> While (cnnConn.State = adStateConnecting)
>>>> DoEvents
>>>> Wend
>>>> 'vérifie que le recordset est bien fermée
>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Clos e
>>>> 'ouvre le recordset
>>>> rstRecordset.Open tempQuery, cnnConn
>>>> 'transpose recordset dans grid
>>>> Set VSFlexGrid1.DataSource = rstRecordset
>>>> 'si recordset encore ouvert alors le ferme
>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Clos e
>>>> 'si connection encore ouverte alors la ferme
>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>> 'libere objets
>>>> Set cnnConn = Nothing
>>>> Set rstRecordset = Nothing
>>>> End Sub
>>>> --------------------------------------------
>>>> ainsi que quelques constantes définies dans un module
>>>> --------------------------------------------
>>>> Public Const AppVersion = "0.2.9"
>>>> Public Const AppInDevMode = True
>>>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
>>>> Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLED B.
>>>> 4.0;"
>>>> --------------------------------------------
>>>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
>>>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
>>>> nickel sans problémes les données de la base de données sont l ues et
>>>> affichés dans le grid.
>>>> mais si je n'ai pas de point d'arret, tout le code est executé et a la
>>>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
>>>> d'aprés quelques debug.print que j'ai mis)
>>>> Quelqu'un saurait pourquoi ?
si je le mets la :
...If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.CloseWhile état1 = adStateClosed
état1 = rstRecordset.State
Wend
While état2 = adStateClosed
état2 = cnnConn.State
Wend'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
ben une fois sur deux ça reste dans la boucle car le state est deja
closed
On 28 mar, 14:49, isabelle wrote:Salut altarboy,
juste avant
Set cnnConn = Nothing
Set rstRecordset = Nothing
isabelle
altarboy a écrit :Salut Isabelle,
Je ne vois pas trop ou mettre ces deux boucles.
On 27 mar, 19:17, isabelle wrote:bonjour,
essai en y ajoutant une boucle :
While état1 = adStateClose
état1 = rstRecordset.State
Wend
While état2 = adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :Petite précision :
Si j'enlève du code la partie suivante tout fonctionne sans
problèmes :
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
Normalement on est pas sensés libérer les variables/objets une fois
qu'on a plus besoin ?
On 27 mar, 17:23, seliana wrote:Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues et
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
si je le mets la :
...
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
While état1 = adStateClosed
état1 = rstRecordset.State
Wend
While état2 = adStateClosed
état2 = cnnConn.State
Wend
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
ben une fois sur deux ça reste dans la boucle car le state est deja
closed
On 28 mar, 14:49, isabelle <i@v> wrote:
Salut altarboy,
juste avant
Set cnnConn = Nothing
Set rstRecordset = Nothing
isabelle
altarboy a écrit :
Salut Isabelle,
Je ne vois pas trop ou mettre ces deux boucles.
On 27 mar, 19:17, isabelle <i@v> wrote:
bonjour,
essai en y ajoutant une boucle :
While état1 = adStateClose
état1 = rstRecordset.State
Wend
While état2 = adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
Petite précision :
Si j'enlève du code la partie suivante tout fonctionne sans
problèmes :
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
Normalement on est pas sensés libérer les variables/objets une fois
qu'on a plus besoin ?
On 27 mar, 17:23, seliana <altarbo...@gmail.com> wrote:
Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues et
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
si je le mets la :
...If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.CloseWhile état1 = adStateClosed
état1 = rstRecordset.State
Wend
While état2 = adStateClosed
état2 = cnnConn.State
Wend'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
ben une fois sur deux ça reste dans la boucle car le state est deja
closed
On 28 mar, 14:49, isabelle wrote:Salut altarboy,
juste avant
Set cnnConn = Nothing
Set rstRecordset = Nothing
isabelle
altarboy a écrit :Salut Isabelle,
Je ne vois pas trop ou mettre ces deux boucles.
On 27 mar, 19:17, isabelle wrote:bonjour,
essai en y ajoutant une boucle :
While état1 = adStateClose
état1 = rstRecordset.State
Wend
While état2 = adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :Petite précision :
Si j'enlève du code la partie suivante tout fonctionne sans
problèmes :
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
Normalement on est pas sensés libérer les variables/objets une fois
qu'on a plus besoin ?
On 27 mar, 17:23, seliana wrote:Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues et
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
bonjour,
oups desolé , la correction est :
While état1 <> adStateClose
état1 = rstRecordset.State
Wend
While état2 <> adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
> si je le mets la :
> ...
>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Clo se
>>>>> 'si connection encore ouverte alors la ferme
>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>> While état1 = adStateClosed
>>>> état1 = rstRecordset.State
>>>> Wend
>>>> While état2 = adStateClosed
>>>> état2 = cnnConn.State
>>>> Wend
>>>>> 'libere objets
>>>>> Set cnnConn = Nothing
>>>>> Set rstRecordset = Nothing
> ben une fois sur deux ça reste dans la boucle car le state est deja
> closed
> On 28 mar, 14:49, isabelle wrote:
>> Salut altarboy,
>> juste avant
>> Set cnnConn = Nothing
>> Set rstRecordset = Nothing
>> isabelle
>> altarboy a écrit :
>>> Salut Isabelle,
>>> Je ne vois pas trop ou mettre ces deux boucles.
>>> On 27 mar, 19:17, isabelle wrote:
>>>> bonjour,
>>>> essai en y ajoutant une boucle :
>>>> While état1 = adStateClose
>>>> état1 = rstRecordset.State
>>>> Wend
>>>> While état2 = adStateClose
>>>> état2 = cnnConn.State
>>>> Wend
>>>> isabelle
>>>> altarboy a écrit :
>>>>> Petite précision :
>>>>> Si j'enlève du code la partie suivante tout fonctionne sans
>>>>> problèmes :
>>>>> 'libere objets
>>>>> Set cnnConn = Nothing
>>>>> Set rstRecordset = Nothing
>>>>> Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
>>>>> Normalement on est pas sensés libérer les variables/objets une fois
>>>>> qu'on a plus besoin ?
>>>>> On 27 mar, 17:23, seliana wrote:
>>>>>> Bonjour microsoft.public.fr.excel,
>>>>>> Comment se fait il que le code ci dessous fasse crasher Excel quan d
>>>>>> exécuté sans interruption alors que s'il est exécuté pas à pas tout
>>>>>> fonctionne sans problème.
>>>>>> j'ai sur ma feuille :
>>>>>> calAgent - objet calendrier (microsoft calendar control 11.0)
>>>>>> VSFlexGrid1 - voila :) VS Flex Grid v7
>>>>>> ComboBox1 - objet combobox
>>>>>> ainsi que un bouton (CommandButton1) et quelques textbox et label mais
>>>>>> qui ne sont pas encore utilisés
>>>>>> Voici le code en question.
>>>>>> --------------------------------------------
>>>>>> Option Explicit
>>>>>> 'declaration de variables
>>>>>> Dim cnnConn As ADODB.Connection
>>>>>> Dim rstRecordset As ADODB.recordSet
>>>>>> Dim tempQuery As String
>>>>>> Private Sub CommandButton1_Click()
>>>>>> 'definition de variables
>>>>>> Set cnnConn = New ADODB.Connection
>>>>>> Set rstRecordset = New ADODB.recordSet
>>>>>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
>>>>>> tAgents.percentage, tBEELoginLogout.entryDate,
>>>>>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
>>>>>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
>>>>>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
>>>>>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
>>>>>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout .entryDate)
>>>>>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
>>>>>> "#));"
>>>>>> 'Vérifie que la connexion est bien fermée
>>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>>>> 'Etabli la connection
>>>>>> cnnConn.ConnectionString = CAppConnectionString
>>>>>> cnnConn.Open CAppPathTodB
>>>>>> 'Attente que la connexion soit établie
>>>>>> While (cnnConn.State = adStateConnecting)
>>>>>> DoEvents
>>>>>> Wend
>>>>>> 'vérifie que le recordset est bien fermée
>>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Cl ose
>>>>>> 'ouvre le recordset
>>>>>> rstRecordset.Open tempQuery, cnnConn
>>>>>> 'transpose recordset dans grid
>>>>>> Set VSFlexGrid1.DataSource = rstRecordset
>>>>>> 'si recordset encore ouvert alors le ferme
>>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Cl ose
>>>>>> 'si connection encore ouverte alors la ferme
>>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>>>> 'libere objets
>>>>>> Set cnnConn = Nothing
>>>>>> Set rstRecordset = Nothing
>>>>>> End Sub
>>>>>> --------------------------------------------
>>>>>> ainsi que quelques constantes définies dans un module
>>>>>> --------------------------------------------
>>>>>> Public Const AppVersion = "0.2.9"
>>>>>> Public Const AppInDevMode = True
>>>>>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
>>>>>> Public Const CAppConnectionString = "Provider=Microsoft.Jet.OL EDB.
>>>>>> 4.0;"
>>>>>> --------------------------------------------
>>>>>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur l e
>>>>>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pa s.
>>>>>> nickel sans problémes les données de la base de données sont lues et
>>>>>> affichés dans le grid.
>>>>>> mais si je n'ai pas de point d'arret, tout le code est executé e t a la
>>>>>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub "
>>>>>> d'aprés quelques debug.print que j'ai mis)
>>>>>> Quelqu'un saurait pourquoi ?
bonjour,
oups desolé , la correction est :
While état1 <> adStateClose
état1 = rstRecordset.State
Wend
While état2 <> adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
> si je le mets la :
> ...
>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Clo se
>>>>> 'si connection encore ouverte alors la ferme
>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>> While état1 = adStateClosed
>>>> état1 = rstRecordset.State
>>>> Wend
>>>> While état2 = adStateClosed
>>>> état2 = cnnConn.State
>>>> Wend
>>>>> 'libere objets
>>>>> Set cnnConn = Nothing
>>>>> Set rstRecordset = Nothing
> ben une fois sur deux ça reste dans la boucle car le state est deja
> closed
> On 28 mar, 14:49, isabelle <i@v> wrote:
>> Salut altarboy,
>> juste avant
>> Set cnnConn = Nothing
>> Set rstRecordset = Nothing
>> isabelle
>> altarboy a écrit :
>>> Salut Isabelle,
>>> Je ne vois pas trop ou mettre ces deux boucles.
>>> On 27 mar, 19:17, isabelle <i@v> wrote:
>>>> bonjour,
>>>> essai en y ajoutant une boucle :
>>>> While état1 = adStateClose
>>>> état1 = rstRecordset.State
>>>> Wend
>>>> While état2 = adStateClose
>>>> état2 = cnnConn.State
>>>> Wend
>>>> isabelle
>>>> altarboy a écrit :
>>>>> Petite précision :
>>>>> Si j'enlève du code la partie suivante tout fonctionne sans
>>>>> problèmes :
>>>>> 'libere objets
>>>>> Set cnnConn = Nothing
>>>>> Set rstRecordset = Nothing
>>>>> Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
>>>>> Normalement on est pas sensés libérer les variables/objets une fois
>>>>> qu'on a plus besoin ?
>>>>> On 27 mar, 17:23, seliana <altarbo...@gmail.com> wrote:
>>>>>> Bonjour microsoft.public.fr.excel,
>>>>>> Comment se fait il que le code ci dessous fasse crasher Excel quan d
>>>>>> exécuté sans interruption alors que s'il est exécuté pas à pas tout
>>>>>> fonctionne sans problème.
>>>>>> j'ai sur ma feuille :
>>>>>> calAgent - objet calendrier (microsoft calendar control 11.0)
>>>>>> VSFlexGrid1 - voila :) VS Flex Grid v7
>>>>>> ComboBox1 - objet combobox
>>>>>> ainsi que un bouton (CommandButton1) et quelques textbox et label mais
>>>>>> qui ne sont pas encore utilisés
>>>>>> Voici le code en question.
>>>>>> --------------------------------------------
>>>>>> Option Explicit
>>>>>> 'declaration de variables
>>>>>> Dim cnnConn As ADODB.Connection
>>>>>> Dim rstRecordset As ADODB.recordSet
>>>>>> Dim tempQuery As String
>>>>>> Private Sub CommandButton1_Click()
>>>>>> 'definition de variables
>>>>>> Set cnnConn = New ADODB.Connection
>>>>>> Set rstRecordset = New ADODB.recordSet
>>>>>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
>>>>>> tAgents.percentage, tBEELoginLogout.entryDate,
>>>>>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
>>>>>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
>>>>>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
>>>>>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
>>>>>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout .entryDate)
>>>>>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
>>>>>> "#));"
>>>>>> 'Vérifie que la connexion est bien fermée
>>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>>>> 'Etabli la connection
>>>>>> cnnConn.ConnectionString = CAppConnectionString
>>>>>> cnnConn.Open CAppPathTodB
>>>>>> 'Attente que la connexion soit établie
>>>>>> While (cnnConn.State = adStateConnecting)
>>>>>> DoEvents
>>>>>> Wend
>>>>>> 'vérifie que le recordset est bien fermée
>>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Cl ose
>>>>>> 'ouvre le recordset
>>>>>> rstRecordset.Open tempQuery, cnnConn
>>>>>> 'transpose recordset dans grid
>>>>>> Set VSFlexGrid1.DataSource = rstRecordset
>>>>>> 'si recordset encore ouvert alors le ferme
>>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Cl ose
>>>>>> 'si connection encore ouverte alors la ferme
>>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>>>> 'libere objets
>>>>>> Set cnnConn = Nothing
>>>>>> Set rstRecordset = Nothing
>>>>>> End Sub
>>>>>> --------------------------------------------
>>>>>> ainsi que quelques constantes définies dans un module
>>>>>> --------------------------------------------
>>>>>> Public Const AppVersion = "0.2.9"
>>>>>> Public Const AppInDevMode = True
>>>>>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
>>>>>> Public Const CAppConnectionString = "Provider=Microsoft.Jet.OL EDB.
>>>>>> 4.0;"
>>>>>> --------------------------------------------
>>>>>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur l e
>>>>>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pa s.
>>>>>> nickel sans problémes les données de la base de données sont lues et
>>>>>> affichés dans le grid.
>>>>>> mais si je n'ai pas de point d'arret, tout le code est executé e t a la
>>>>>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub "
>>>>>> d'aprés quelques debug.print que j'ai mis)
>>>>>> Quelqu'un saurait pourquoi ?
bonjour,
oups desolé , la correction est :
While état1 <> adStateClose
état1 = rstRecordset.State
Wend
While état2 <> adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
> si je le mets la :
> ...
>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Clo se
>>>>> 'si connection encore ouverte alors la ferme
>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>> While état1 = adStateClosed
>>>> état1 = rstRecordset.State
>>>> Wend
>>>> While état2 = adStateClosed
>>>> état2 = cnnConn.State
>>>> Wend
>>>>> 'libere objets
>>>>> Set cnnConn = Nothing
>>>>> Set rstRecordset = Nothing
> ben une fois sur deux ça reste dans la boucle car le state est deja
> closed
> On 28 mar, 14:49, isabelle wrote:
>> Salut altarboy,
>> juste avant
>> Set cnnConn = Nothing
>> Set rstRecordset = Nothing
>> isabelle
>> altarboy a écrit :
>>> Salut Isabelle,
>>> Je ne vois pas trop ou mettre ces deux boucles.
>>> On 27 mar, 19:17, isabelle wrote:
>>>> bonjour,
>>>> essai en y ajoutant une boucle :
>>>> While état1 = adStateClose
>>>> état1 = rstRecordset.State
>>>> Wend
>>>> While état2 = adStateClose
>>>> état2 = cnnConn.State
>>>> Wend
>>>> isabelle
>>>> altarboy a écrit :
>>>>> Petite précision :
>>>>> Si j'enlève du code la partie suivante tout fonctionne sans
>>>>> problèmes :
>>>>> 'libere objets
>>>>> Set cnnConn = Nothing
>>>>> Set rstRecordset = Nothing
>>>>> Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
>>>>> Normalement on est pas sensés libérer les variables/objets une fois
>>>>> qu'on a plus besoin ?
>>>>> On 27 mar, 17:23, seliana wrote:
>>>>>> Bonjour microsoft.public.fr.excel,
>>>>>> Comment se fait il que le code ci dessous fasse crasher Excel quan d
>>>>>> exécuté sans interruption alors que s'il est exécuté pas à pas tout
>>>>>> fonctionne sans problème.
>>>>>> j'ai sur ma feuille :
>>>>>> calAgent - objet calendrier (microsoft calendar control 11.0)
>>>>>> VSFlexGrid1 - voila :) VS Flex Grid v7
>>>>>> ComboBox1 - objet combobox
>>>>>> ainsi que un bouton (CommandButton1) et quelques textbox et label mais
>>>>>> qui ne sont pas encore utilisés
>>>>>> Voici le code en question.
>>>>>> --------------------------------------------
>>>>>> Option Explicit
>>>>>> 'declaration de variables
>>>>>> Dim cnnConn As ADODB.Connection
>>>>>> Dim rstRecordset As ADODB.recordSet
>>>>>> Dim tempQuery As String
>>>>>> Private Sub CommandButton1_Click()
>>>>>> 'definition de variables
>>>>>> Set cnnConn = New ADODB.Connection
>>>>>> Set rstRecordset = New ADODB.recordSet
>>>>>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
>>>>>> tAgents.percentage, tBEELoginLogout.entryDate,
>>>>>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
>>>>>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
>>>>>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
>>>>>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
>>>>>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout .entryDate)
>>>>>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
>>>>>> "#));"
>>>>>> 'Vérifie que la connexion est bien fermée
>>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>>>> 'Etabli la connection
>>>>>> cnnConn.ConnectionString = CAppConnectionString
>>>>>> cnnConn.Open CAppPathTodB
>>>>>> 'Attente que la connexion soit établie
>>>>>> While (cnnConn.State = adStateConnecting)
>>>>>> DoEvents
>>>>>> Wend
>>>>>> 'vérifie que le recordset est bien fermée
>>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Cl ose
>>>>>> 'ouvre le recordset
>>>>>> rstRecordset.Open tempQuery, cnnConn
>>>>>> 'transpose recordset dans grid
>>>>>> Set VSFlexGrid1.DataSource = rstRecordset
>>>>>> 'si recordset encore ouvert alors le ferme
>>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Cl ose
>>>>>> 'si connection encore ouverte alors la ferme
>>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>>>> 'libere objets
>>>>>> Set cnnConn = Nothing
>>>>>> Set rstRecordset = Nothing
>>>>>> End Sub
>>>>>> --------------------------------------------
>>>>>> ainsi que quelques constantes définies dans un module
>>>>>> --------------------------------------------
>>>>>> Public Const AppVersion = "0.2.9"
>>>>>> Public Const AppInDevMode = True
>>>>>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
>>>>>> Public Const CAppConnectionString = "Provider=Microsoft.Jet.OL EDB.
>>>>>> 4.0;"
>>>>>> --------------------------------------------
>>>>>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur l e
>>>>>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pa s.
>>>>>> nickel sans problémes les données de la base de données sont lues et
>>>>>> affichés dans le grid.
>>>>>> mais si je n'ai pas de point d'arret, tout le code est executé e t a la
>>>>>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub "
>>>>>> d'aprés quelques debug.print que j'ai mis)
>>>>>> Quelqu'un saurait pourquoi ?
bonjour,
oups desolé , la correction est :
While état1 <> adStateClose
état1 = rstRecordset.State
Wend
While état2 <> adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
> si je le mets la :
> ...
>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>>>>> 'si connection encore ouverte alors la ferme
>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>> While état1 = adStateClosed
>>>> état1 = rstRecordset.State
>>>> Wend
>>>> While état2 = adStateClosed
>>>> état2 = cnnConn.State
>>>> Wend
>>>>> 'libere objets
>>>>> Set cnnConn = Nothing
>>>>> Set rstRecordset = Nothing
> ben une fois sur deux ça reste dans la boucle car le state est deja
> closed
> On 28 mar, 14:49, isabelle wrote:
>> Salut altarboy,
>> juste avant
>> Set cnnConn = Nothing
>> Set rstRecordset = Nothing
>> isabelle
>> altarboy a écrit :
>>> Salut Isabelle,
>>> Je ne vois pas trop ou mettre ces deux boucles.
>>> On 27 mar, 19:17, isabelle wrote:
>>>> bonjour,
>>>> essai en y ajoutant une boucle :
>>>> While état1 = adStateClose
>>>> état1 = rstRecordset.State
>>>> Wend
>>>> While état2 = adStateClose
>>>> état2 = cnnConn.State
>>>> Wend
>>>> isabelle
>>>> altarboy a écrit :
>>>>> Petite précision :
>>>>> Si j'enlève du code la partie suivante tout fonctionne sans
>>>>> problèmes :
>>>>> 'libere objets
>>>>> Set cnnConn = Nothing
>>>>> Set rstRecordset = Nothing
>>>>> Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
>>>>> Normalement on est pas sensés libérer les variables/objets une fois
>>>>> qu'on a plus besoin ?
>>>>> On 27 mar, 17:23, seliana wrote:
>>>>>> Bonjour microsoft.public.fr.excel,
>>>>>> Comment se fait il que le code ci dessous fasse crasher Excel quand
>>>>>> exécuté sans interruption alors que s'il est exécuté pas à pas tout
>>>>>> fonctionne sans problème.
>>>>>> j'ai sur ma feuille :
>>>>>> calAgent - objet calendrier (microsoft calendar control 11.0)
>>>>>> VSFlexGrid1 - voila :) VS Flex Grid v7
>>>>>> ComboBox1 - objet combobox
>>>>>> ainsi que un bouton (CommandButton1) et quelques textbox et label
>>>>>> qui ne sont pas encore utilisés
>>>>>> Voici le code en question.
>>>>>> --------------------------------------------
>>>>>> Option Explicit
>>>>>> 'declaration de variables
>>>>>> Dim cnnConn As ADODB.Connection
>>>>>> Dim rstRecordset As ADODB.recordSet
>>>>>> Dim tempQuery As String
>>>>>> Private Sub CommandButton1_Click()
>>>>>> 'definition de variables
>>>>>> Set cnnConn = New ADODB.Connection
>>>>>> Set rstRecordset = New ADODB.recordSet
>>>>>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
>>>>>> tAgents.percentage, tBEELoginLogout.entryDate,
>>>>>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
>>>>>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
>>>>>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
>>>>>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
>>>>>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
>>>>>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
>>>>>> "#));"
>>>>>> 'Vérifie que la connexion est bien fermée
>>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>>>> 'Etabli la connection
>>>>>> cnnConn.ConnectionString = CAppConnectionString
>>>>>> cnnConn.Open CAppPathTodB
>>>>>> 'Attente que la connexion soit établie
>>>>>> While (cnnConn.State = adStateConnecting)
>>>>>> DoEvents
>>>>>> Wend
>>>>>> 'vérifie que le recordset est bien fermée
>>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>>>>>> 'ouvre le recordset
>>>>>> rstRecordset.Open tempQuery, cnnConn
>>>>>> 'transpose recordset dans grid
>>>>>> Set VSFlexGrid1.DataSource = rstRecordset
>>>>>> 'si recordset encore ouvert alors le ferme
>>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>>>>>> 'si connection encore ouverte alors la ferme
>>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>>>> 'libere objets
>>>>>> Set cnnConn = Nothing
>>>>>> Set rstRecordset = Nothing
>>>>>> End Sub
>>>>>> --------------------------------------------
>>>>>> ainsi que quelques constantes définies dans un module
>>>>>> --------------------------------------------
>>>>>> Public Const AppVersion = "0.2.9"
>>>>>> Public Const AppInDevMode = True
>>>>>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
>>>>>> Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
>>>>>> 4.0;"
>>>>>> --------------------------------------------
>>>>>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
>>>>>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
>>>>>> nickel sans problémes les données de la base de données sont lues
>>>>>> affichés dans le grid.
>>>>>> mais si je n'ai pas de point d'arret, tout le code est executé et a
>>>>>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
>>>>>> d'aprés quelques debug.print que j'ai mis)
>>>>>> Quelqu'un saurait pourquoi ?
bonjour,
oups desolé , la correction est :
While état1 <> adStateClose
état1 = rstRecordset.State
Wend
While état2 <> adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
> si je le mets la :
> ...
>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>>>>> 'si connection encore ouverte alors la ferme
>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>> While état1 = adStateClosed
>>>> état1 = rstRecordset.State
>>>> Wend
>>>> While état2 = adStateClosed
>>>> état2 = cnnConn.State
>>>> Wend
>>>>> 'libere objets
>>>>> Set cnnConn = Nothing
>>>>> Set rstRecordset = Nothing
> ben une fois sur deux ça reste dans la boucle car le state est deja
> closed
> On 28 mar, 14:49, isabelle <i@v> wrote:
>> Salut altarboy,
>> juste avant
>> Set cnnConn = Nothing
>> Set rstRecordset = Nothing
>> isabelle
>> altarboy a écrit :
>>> Salut Isabelle,
>>> Je ne vois pas trop ou mettre ces deux boucles.
>>> On 27 mar, 19:17, isabelle <i@v> wrote:
>>>> bonjour,
>>>> essai en y ajoutant une boucle :
>>>> While état1 = adStateClose
>>>> état1 = rstRecordset.State
>>>> Wend
>>>> While état2 = adStateClose
>>>> état2 = cnnConn.State
>>>> Wend
>>>> isabelle
>>>> altarboy a écrit :
>>>>> Petite précision :
>>>>> Si j'enlève du code la partie suivante tout fonctionne sans
>>>>> problèmes :
>>>>> 'libere objets
>>>>> Set cnnConn = Nothing
>>>>> Set rstRecordset = Nothing
>>>>> Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
>>>>> Normalement on est pas sensés libérer les variables/objets une fois
>>>>> qu'on a plus besoin ?
>>>>> On 27 mar, 17:23, seliana <altarbo...@gmail.com> wrote:
>>>>>> Bonjour microsoft.public.fr.excel,
>>>>>> Comment se fait il que le code ci dessous fasse crasher Excel quand
>>>>>> exécuté sans interruption alors que s'il est exécuté pas à pas tout
>>>>>> fonctionne sans problème.
>>>>>> j'ai sur ma feuille :
>>>>>> calAgent - objet calendrier (microsoft calendar control 11.0)
>>>>>> VSFlexGrid1 - voila :) VS Flex Grid v7
>>>>>> ComboBox1 - objet combobox
>>>>>> ainsi que un bouton (CommandButton1) et quelques textbox et label
>>>>>> qui ne sont pas encore utilisés
>>>>>> Voici le code en question.
>>>>>> --------------------------------------------
>>>>>> Option Explicit
>>>>>> 'declaration de variables
>>>>>> Dim cnnConn As ADODB.Connection
>>>>>> Dim rstRecordset As ADODB.recordSet
>>>>>> Dim tempQuery As String
>>>>>> Private Sub CommandButton1_Click()
>>>>>> 'definition de variables
>>>>>> Set cnnConn = New ADODB.Connection
>>>>>> Set rstRecordset = New ADODB.recordSet
>>>>>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
>>>>>> tAgents.percentage, tBEELoginLogout.entryDate,
>>>>>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
>>>>>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
>>>>>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
>>>>>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
>>>>>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
>>>>>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
>>>>>> "#));"
>>>>>> 'Vérifie que la connexion est bien fermée
>>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>>>> 'Etabli la connection
>>>>>> cnnConn.ConnectionString = CAppConnectionString
>>>>>> cnnConn.Open CAppPathTodB
>>>>>> 'Attente que la connexion soit établie
>>>>>> While (cnnConn.State = adStateConnecting)
>>>>>> DoEvents
>>>>>> Wend
>>>>>> 'vérifie que le recordset est bien fermée
>>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>>>>>> 'ouvre le recordset
>>>>>> rstRecordset.Open tempQuery, cnnConn
>>>>>> 'transpose recordset dans grid
>>>>>> Set VSFlexGrid1.DataSource = rstRecordset
>>>>>> 'si recordset encore ouvert alors le ferme
>>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>>>>>> 'si connection encore ouverte alors la ferme
>>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>>>> 'libere objets
>>>>>> Set cnnConn = Nothing
>>>>>> Set rstRecordset = Nothing
>>>>>> End Sub
>>>>>> --------------------------------------------
>>>>>> ainsi que quelques constantes définies dans un module
>>>>>> --------------------------------------------
>>>>>> Public Const AppVersion = "0.2.9"
>>>>>> Public Const AppInDevMode = True
>>>>>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
>>>>>> Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
>>>>>> 4.0;"
>>>>>> --------------------------------------------
>>>>>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
>>>>>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
>>>>>> nickel sans problémes les données de la base de données sont lues
>>>>>> affichés dans le grid.
>>>>>> mais si je n'ai pas de point d'arret, tout le code est executé et a
>>>>>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
>>>>>> d'aprés quelques debug.print que j'ai mis)
>>>>>> Quelqu'un saurait pourquoi ?
bonjour,
oups desolé , la correction est :
While état1 <> adStateClose
état1 = rstRecordset.State
Wend
While état2 <> adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
> si je le mets la :
> ...
>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>>>>> 'si connection encore ouverte alors la ferme
>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>> While état1 = adStateClosed
>>>> état1 = rstRecordset.State
>>>> Wend
>>>> While état2 = adStateClosed
>>>> état2 = cnnConn.State
>>>> Wend
>>>>> 'libere objets
>>>>> Set cnnConn = Nothing
>>>>> Set rstRecordset = Nothing
> ben une fois sur deux ça reste dans la boucle car le state est deja
> closed
> On 28 mar, 14:49, isabelle wrote:
>> Salut altarboy,
>> juste avant
>> Set cnnConn = Nothing
>> Set rstRecordset = Nothing
>> isabelle
>> altarboy a écrit :
>>> Salut Isabelle,
>>> Je ne vois pas trop ou mettre ces deux boucles.
>>> On 27 mar, 19:17, isabelle wrote:
>>>> bonjour,
>>>> essai en y ajoutant une boucle :
>>>> While état1 = adStateClose
>>>> état1 = rstRecordset.State
>>>> Wend
>>>> While état2 = adStateClose
>>>> état2 = cnnConn.State
>>>> Wend
>>>> isabelle
>>>> altarboy a écrit :
>>>>> Petite précision :
>>>>> Si j'enlève du code la partie suivante tout fonctionne sans
>>>>> problèmes :
>>>>> 'libere objets
>>>>> Set cnnConn = Nothing
>>>>> Set rstRecordset = Nothing
>>>>> Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
>>>>> Normalement on est pas sensés libérer les variables/objets une fois
>>>>> qu'on a plus besoin ?
>>>>> On 27 mar, 17:23, seliana wrote:
>>>>>> Bonjour microsoft.public.fr.excel,
>>>>>> Comment se fait il que le code ci dessous fasse crasher Excel quand
>>>>>> exécuté sans interruption alors que s'il est exécuté pas à pas tout
>>>>>> fonctionne sans problème.
>>>>>> j'ai sur ma feuille :
>>>>>> calAgent - objet calendrier (microsoft calendar control 11.0)
>>>>>> VSFlexGrid1 - voila :) VS Flex Grid v7
>>>>>> ComboBox1 - objet combobox
>>>>>> ainsi que un bouton (CommandButton1) et quelques textbox et label
>>>>>> qui ne sont pas encore utilisés
>>>>>> Voici le code en question.
>>>>>> --------------------------------------------
>>>>>> Option Explicit
>>>>>> 'declaration de variables
>>>>>> Dim cnnConn As ADODB.Connection
>>>>>> Dim rstRecordset As ADODB.recordSet
>>>>>> Dim tempQuery As String
>>>>>> Private Sub CommandButton1_Click()
>>>>>> 'definition de variables
>>>>>> Set cnnConn = New ADODB.Connection
>>>>>> Set rstRecordset = New ADODB.recordSet
>>>>>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
>>>>>> tAgents.percentage, tBEELoginLogout.entryDate,
>>>>>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
>>>>>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
>>>>>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
>>>>>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
>>>>>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
>>>>>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
>>>>>> "#));"
>>>>>> 'Vérifie que la connexion est bien fermée
>>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>>>> 'Etabli la connection
>>>>>> cnnConn.ConnectionString = CAppConnectionString
>>>>>> cnnConn.Open CAppPathTodB
>>>>>> 'Attente que la connexion soit établie
>>>>>> While (cnnConn.State = adStateConnecting)
>>>>>> DoEvents
>>>>>> Wend
>>>>>> 'vérifie que le recordset est bien fermée
>>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>>>>>> 'ouvre le recordset
>>>>>> rstRecordset.Open tempQuery, cnnConn
>>>>>> 'transpose recordset dans grid
>>>>>> Set VSFlexGrid1.DataSource = rstRecordset
>>>>>> 'si recordset encore ouvert alors le ferme
>>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
>>>>>> 'si connection encore ouverte alors la ferme
>>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
>>>>>> 'libere objets
>>>>>> Set cnnConn = Nothing
>>>>>> Set rstRecordset = Nothing
>>>>>> End Sub
>>>>>> --------------------------------------------
>>>>>> ainsi que quelques constantes définies dans un module
>>>>>> --------------------------------------------
>>>>>> Public Const AppVersion = "0.2.9"
>>>>>> Public Const AppInDevMode = True
>>>>>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
>>>>>> Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
>>>>>> 4.0;"
>>>>>> --------------------------------------------
>>>>>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
>>>>>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
>>>>>> nickel sans problémes les données de la base de données sont lues
>>>>>> affichés dans le grid.
>>>>>> mais si je n'ai pas de point d'arret, tout le code est executé et a
>>>>>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
>>>>>> d'aprés quelques debug.print que j'ai mis)
>>>>>> Quelqu'un saurait pourquoi ?
Bonjour
As-tu essayé de rajouter un Doevents avant les
Set cnnConn = Nothing
Set rstRecordset = Nothing
--
Cordialement,
Gilbert
"altarboy" a écrit dans le message denews:74607e
Salut
Effectivement, ça a l'air plus logique, malheureusement ça ne change
rien. ça crash toujours quand je set les variables = Nothing.
De quoi m'arracher les cheveux. Heureusement que j'en ai plus.
On 28 mar, 15:45, isabelle wrote:
> bonjour,
> oups desolé , la correction est :
> While état1 <> adStateClose
> état1 = rstRecordset.State
> Wend
> While état2 <> adStateClose
> état2 = cnnConn.State
> Wend
> isabelle
> altarboy a écrit :
> > si je le mets la :
> > ...
> >>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
> >>>>> 'si connection encore ouverte alors la ferme
> >>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
> >>>> While état1 = adStateClosed
> >>>> état1 = rstRecordset.State
> >>>> Wend
> >>>> While état2 = adStateClosed
> >>>> état2 = cnnConn.State
> >>>> Wend
> >>>>> 'libere objets
> >>>>> Set cnnConn = Nothing
> >>>>> Set rstRecordset = Nothing
> > ben une fois sur deux ça reste dans la boucle car le state est deja
> > closed
> > On 28 mar, 14:49, isabelle wrote:
> >> Salut altarboy,
> >> juste avant
> >> Set cnnConn = Nothing
> >> Set rstRecordset = Nothing
> >> isabelle
> >> altarboy a écrit :
> >>> Salut Isabelle,
> >>> Je ne vois pas trop ou mettre ces deux boucles.
> >>> On 27 mar, 19:17, isabelle wrote:
> >>>> bonjour,
> >>>> essai en y ajoutant une boucle :
> >>>> While état1 = adStateClose
> >>>> état1 = rstRecordset.State
> >>>> Wend
> >>>> While état2 = adStateClose
> >>>> état2 = cnnConn.State
> >>>> Wend
> >>>> isabelle
> >>>> altarboy a écrit :
> >>>>> Petite précision :
> >>>>> Si j'enlève du code la partie suivante tout fonctionne sans
> >>>>> problèmes :
> >>>>> 'libere objets
> >>>>> Set cnnConn = Nothing
> >>>>> Set rstRecordset = Nothing
> >>>>> Alors soit je deviens trop vieux soit ..... je deviens trop vieux .
> >>>>> Normalement on est pas sensés libérer les variables/objets un e fois
> >>>>> qu'on a plus besoin ?
> >>>>> On 27 mar, 17:23, seliana wrote:
> >>>>>> Bonjour microsoft.public.fr.excel,
> >>>>>> Comment se fait il que le code ci dessous fasse crasher Excel qu and
> >>>>>> exécuté sans interruption alors que s'il est exécuté pas à pas tout
> >>>>>> fonctionne sans problème.
> >>>>>> j'ai sur ma feuille :
> >>>>>> calAgent - objet calendrier (microsoft calendar control 11.0)
> >>>>>> VSFlexGrid1 - voila :) VS Flex Grid v7
> >>>>>> ComboBox1 - objet combobox
> >>>>>> ainsi que un bouton (CommandButton1) et quelques textbox et labe l
mais
> >>>>>> qui ne sont pas encore utilisés
> >>>>>> Voici le code en question.
> >>>>>> --------------------------------------------
> >>>>>> Option Explicit
> >>>>>> 'declaration de variables
> >>>>>> Dim cnnConn As ADODB.Connection
> >>>>>> Dim rstRecordset As ADODB.recordSet
> >>>>>> Dim tempQuery As String
> >>>>>> Private Sub CommandButton1_Click()
> >>>>>> 'definition de variables
> >>>>>> Set cnnConn = New ADODB.Connection
> >>>>>> Set rstRecordset = New ADODB.recordSet
> >>>>>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
> >>>>>> tAgents.percentage, tBEELoginLogout.entryDate,
> >>>>>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
> >>>>>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
> >>>>>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
> >>>>>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.val ue
> >>>>>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entry Date)
> >>>>>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Yea r &
> >>>>>> "#));"
> >>>>>> 'Vérifie que la connexion est bien fermée
> >>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
> >>>>>> 'Etabli la connection
> >>>>>> cnnConn.ConnectionString = CAppConnectionString
> >>>>>> cnnConn.Open CAppPathTodB
> >>>>>> 'Attente que la connexion soit établie
> >>>>>> While (cnnConn.State = adStateConnecting)
> >>>>>> DoEvents
> >>>>>> Wend
> >>>>>> 'vérifie que le recordset est bien fermée
> >>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
> >>>>>> 'ouvre le recordset
> >>>>>> rstRecordset.Open tempQuery, cnnConn
> >>>>>> 'transpose recordset dans grid
> >>>>>> Set VSFlexGrid1.DataSource = rstRecordset
> >>>>>> 'si recordset encore ouvert alors le ferme
> >>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
> >>>>>> 'si connection encore ouverte alors la ferme
> >>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
> >>>>>> 'libere objets
> >>>>>> Set cnnConn = Nothing
> >>>>>> Set rstRecordset = Nothing
> >>>>>> End Sub
> >>>>>> --------------------------------------------
> >>>>>> ainsi que quelques constantes définies dans un module
> >>>>>> --------------------------------------------
> >>>>>> Public Const AppVersion = "0.2.9"
> >>>>>> Public Const AppInDevMode = True
> >>>>>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
> >>>>>> Public Const CAppConnectionString = "Provider=Microsoft.Jet. OLEDB.
> >>>>>> 4.0;"
> >>>>>> --------------------------------------------
> >>>>>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
> >>>>>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
> >>>>>> nickel sans problémes les données de la base de données so nt lues
et
> >>>>>> affichés dans le grid.
> >>>>>> mais si je n'ai pas de point d'arret, tout le code est executé et a
la
> >>>>>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End S ub"
> >>>>>> d'aprés quelques debug.print que j'ai mis)
> >>>>>> Quelqu'un saurait pourquoi ?
Bonjour
As-tu essayé de rajouter un Doevents avant les
Set cnnConn = Nothing
Set rstRecordset = Nothing
--
Cordialement,
Gilbert
"altarboy" <altarbo...@gmail.com> a écrit dans le message denews:74607e 49-31bd-4f9a-b7a2-dbc21c900d9e@f19g2000yqo.googlegroups.com...
Salut
Effectivement, ça a l'air plus logique, malheureusement ça ne change
rien. ça crash toujours quand je set les variables = Nothing.
De quoi m'arracher les cheveux. Heureusement que j'en ai plus.
On 28 mar, 15:45, isabelle <i@v> wrote:
> bonjour,
> oups desolé , la correction est :
> While état1 <> adStateClose
> état1 = rstRecordset.State
> Wend
> While état2 <> adStateClose
> état2 = cnnConn.State
> Wend
> isabelle
> altarboy a écrit :
> > si je le mets la :
> > ...
> >>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
> >>>>> 'si connection encore ouverte alors la ferme
> >>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
> >>>> While état1 = adStateClosed
> >>>> état1 = rstRecordset.State
> >>>> Wend
> >>>> While état2 = adStateClosed
> >>>> état2 = cnnConn.State
> >>>> Wend
> >>>>> 'libere objets
> >>>>> Set cnnConn = Nothing
> >>>>> Set rstRecordset = Nothing
> > ben une fois sur deux ça reste dans la boucle car le state est deja
> > closed
> > On 28 mar, 14:49, isabelle <i@v> wrote:
> >> Salut altarboy,
> >> juste avant
> >> Set cnnConn = Nothing
> >> Set rstRecordset = Nothing
> >> isabelle
> >> altarboy a écrit :
> >>> Salut Isabelle,
> >>> Je ne vois pas trop ou mettre ces deux boucles.
> >>> On 27 mar, 19:17, isabelle <i@v> wrote:
> >>>> bonjour,
> >>>> essai en y ajoutant une boucle :
> >>>> While état1 = adStateClose
> >>>> état1 = rstRecordset.State
> >>>> Wend
> >>>> While état2 = adStateClose
> >>>> état2 = cnnConn.State
> >>>> Wend
> >>>> isabelle
> >>>> altarboy a écrit :
> >>>>> Petite précision :
> >>>>> Si j'enlève du code la partie suivante tout fonctionne sans
> >>>>> problèmes :
> >>>>> 'libere objets
> >>>>> Set cnnConn = Nothing
> >>>>> Set rstRecordset = Nothing
> >>>>> Alors soit je deviens trop vieux soit ..... je deviens trop vieux .
> >>>>> Normalement on est pas sensés libérer les variables/objets un e fois
> >>>>> qu'on a plus besoin ?
> >>>>> On 27 mar, 17:23, seliana <altarbo...@gmail.com> wrote:
> >>>>>> Bonjour microsoft.public.fr.excel,
> >>>>>> Comment se fait il que le code ci dessous fasse crasher Excel qu and
> >>>>>> exécuté sans interruption alors que s'il est exécuté pas à pas tout
> >>>>>> fonctionne sans problème.
> >>>>>> j'ai sur ma feuille :
> >>>>>> calAgent - objet calendrier (microsoft calendar control 11.0)
> >>>>>> VSFlexGrid1 - voila :) VS Flex Grid v7
> >>>>>> ComboBox1 - objet combobox
> >>>>>> ainsi que un bouton (CommandButton1) et quelques textbox et labe l
mais
> >>>>>> qui ne sont pas encore utilisés
> >>>>>> Voici le code en question.
> >>>>>> --------------------------------------------
> >>>>>> Option Explicit
> >>>>>> 'declaration de variables
> >>>>>> Dim cnnConn As ADODB.Connection
> >>>>>> Dim rstRecordset As ADODB.recordSet
> >>>>>> Dim tempQuery As String
> >>>>>> Private Sub CommandButton1_Click()
> >>>>>> 'definition de variables
> >>>>>> Set cnnConn = New ADODB.Connection
> >>>>>> Set rstRecordset = New ADODB.recordSet
> >>>>>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
> >>>>>> tAgents.percentage, tBEELoginLogout.entryDate,
> >>>>>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
> >>>>>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
> >>>>>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
> >>>>>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.val ue
> >>>>>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entry Date)
> >>>>>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Yea r &
> >>>>>> "#));"
> >>>>>> 'Vérifie que la connexion est bien fermée
> >>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
> >>>>>> 'Etabli la connection
> >>>>>> cnnConn.ConnectionString = CAppConnectionString
> >>>>>> cnnConn.Open CAppPathTodB
> >>>>>> 'Attente que la connexion soit établie
> >>>>>> While (cnnConn.State = adStateConnecting)
> >>>>>> DoEvents
> >>>>>> Wend
> >>>>>> 'vérifie que le recordset est bien fermée
> >>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
> >>>>>> 'ouvre le recordset
> >>>>>> rstRecordset.Open tempQuery, cnnConn
> >>>>>> 'transpose recordset dans grid
> >>>>>> Set VSFlexGrid1.DataSource = rstRecordset
> >>>>>> 'si recordset encore ouvert alors le ferme
> >>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
> >>>>>> 'si connection encore ouverte alors la ferme
> >>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
> >>>>>> 'libere objets
> >>>>>> Set cnnConn = Nothing
> >>>>>> Set rstRecordset = Nothing
> >>>>>> End Sub
> >>>>>> --------------------------------------------
> >>>>>> ainsi que quelques constantes définies dans un module
> >>>>>> --------------------------------------------
> >>>>>> Public Const AppVersion = "0.2.9"
> >>>>>> Public Const AppInDevMode = True
> >>>>>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
> >>>>>> Public Const CAppConnectionString = "Provider=Microsoft.Jet. OLEDB.
> >>>>>> 4.0;"
> >>>>>> --------------------------------------------
> >>>>>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
> >>>>>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
> >>>>>> nickel sans problémes les données de la base de données so nt lues
et
> >>>>>> affichés dans le grid.
> >>>>>> mais si je n'ai pas de point d'arret, tout le code est executé et a
la
> >>>>>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End S ub"
> >>>>>> d'aprés quelques debug.print que j'ai mis)
> >>>>>> Quelqu'un saurait pourquoi ?
Bonjour
As-tu essayé de rajouter un Doevents avant les
Set cnnConn = Nothing
Set rstRecordset = Nothing
--
Cordialement,
Gilbert
"altarboy" a écrit dans le message denews:74607e
Salut
Effectivement, ça a l'air plus logique, malheureusement ça ne change
rien. ça crash toujours quand je set les variables = Nothing.
De quoi m'arracher les cheveux. Heureusement que j'en ai plus.
On 28 mar, 15:45, isabelle wrote:
> bonjour,
> oups desolé , la correction est :
> While état1 <> adStateClose
> état1 = rstRecordset.State
> Wend
> While état2 <> adStateClose
> état2 = cnnConn.State
> Wend
> isabelle
> altarboy a écrit :
> > si je le mets la :
> > ...
> >>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
> >>>>> 'si connection encore ouverte alors la ferme
> >>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
> >>>> While état1 = adStateClosed
> >>>> état1 = rstRecordset.State
> >>>> Wend
> >>>> While état2 = adStateClosed
> >>>> état2 = cnnConn.State
> >>>> Wend
> >>>>> 'libere objets
> >>>>> Set cnnConn = Nothing
> >>>>> Set rstRecordset = Nothing
> > ben une fois sur deux ça reste dans la boucle car le state est deja
> > closed
> > On 28 mar, 14:49, isabelle wrote:
> >> Salut altarboy,
> >> juste avant
> >> Set cnnConn = Nothing
> >> Set rstRecordset = Nothing
> >> isabelle
> >> altarboy a écrit :
> >>> Salut Isabelle,
> >>> Je ne vois pas trop ou mettre ces deux boucles.
> >>> On 27 mar, 19:17, isabelle wrote:
> >>>> bonjour,
> >>>> essai en y ajoutant une boucle :
> >>>> While état1 = adStateClose
> >>>> état1 = rstRecordset.State
> >>>> Wend
> >>>> While état2 = adStateClose
> >>>> état2 = cnnConn.State
> >>>> Wend
> >>>> isabelle
> >>>> altarboy a écrit :
> >>>>> Petite précision :
> >>>>> Si j'enlève du code la partie suivante tout fonctionne sans
> >>>>> problèmes :
> >>>>> 'libere objets
> >>>>> Set cnnConn = Nothing
> >>>>> Set rstRecordset = Nothing
> >>>>> Alors soit je deviens trop vieux soit ..... je deviens trop vieux .
> >>>>> Normalement on est pas sensés libérer les variables/objets un e fois
> >>>>> qu'on a plus besoin ?
> >>>>> On 27 mar, 17:23, seliana wrote:
> >>>>>> Bonjour microsoft.public.fr.excel,
> >>>>>> Comment se fait il que le code ci dessous fasse crasher Excel qu and
> >>>>>> exécuté sans interruption alors que s'il est exécuté pas à pas tout
> >>>>>> fonctionne sans problème.
> >>>>>> j'ai sur ma feuille :
> >>>>>> calAgent - objet calendrier (microsoft calendar control 11.0)
> >>>>>> VSFlexGrid1 - voila :) VS Flex Grid v7
> >>>>>> ComboBox1 - objet combobox
> >>>>>> ainsi que un bouton (CommandButton1) et quelques textbox et labe l
mais
> >>>>>> qui ne sont pas encore utilisés
> >>>>>> Voici le code en question.
> >>>>>> --------------------------------------------
> >>>>>> Option Explicit
> >>>>>> 'declaration de variables
> >>>>>> Dim cnnConn As ADODB.Connection
> >>>>>> Dim rstRecordset As ADODB.recordSet
> >>>>>> Dim tempQuery As String
> >>>>>> Private Sub CommandButton1_Click()
> >>>>>> 'definition de variables
> >>>>>> Set cnnConn = New ADODB.Connection
> >>>>>> Set rstRecordset = New ADODB.recordSet
> >>>>>> tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
> >>>>>> tAgents.percentage, tBEELoginLogout.entryDate,
> >>>>>> tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
> >>>>>> tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
> >>>>>> tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
> >>>>>> (((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.val ue
> >>>>>> tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entry Date)
> >>>>>> =#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Yea r &
> >>>>>> "#));"
> >>>>>> 'Vérifie que la connexion est bien fermée
> >>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
> >>>>>> 'Etabli la connection
> >>>>>> cnnConn.ConnectionString = CAppConnectionString
> >>>>>> cnnConn.Open CAppPathTodB
> >>>>>> 'Attente que la connexion soit établie
> >>>>>> While (cnnConn.State = adStateConnecting)
> >>>>>> DoEvents
> >>>>>> Wend
> >>>>>> 'vérifie que le recordset est bien fermée
> >>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
> >>>>>> 'ouvre le recordset
> >>>>>> rstRecordset.Open tempQuery, cnnConn
> >>>>>> 'transpose recordset dans grid
> >>>>>> Set VSFlexGrid1.DataSource = rstRecordset
> >>>>>> 'si recordset encore ouvert alors le ferme
> >>>>>> If rstRecordset.State = adStateOpen Then rstRecordset.Close
> >>>>>> 'si connection encore ouverte alors la ferme
> >>>>>> If cnnConn.State = adStateOpen Then cnnConn.Close
> >>>>>> 'libere objets
> >>>>>> Set cnnConn = Nothing
> >>>>>> Set rstRecordset = Nothing
> >>>>>> End Sub
> >>>>>> --------------------------------------------
> >>>>>> ainsi que quelques constantes définies dans un module
> >>>>>> --------------------------------------------
> >>>>>> Public Const AppVersion = "0.2.9"
> >>>>>> Public Const AppInDevMode = True
> >>>>>> Public Const CAppPathTodB = "U:_devfifomain.mdb"
> >>>>>> Public Const CAppConnectionString = "Provider=Microsoft.Jet. OLEDB.
> >>>>>> 4.0;"
> >>>>>> --------------------------------------------
> >>>>>> Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
> >>>>>> debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
> >>>>>> nickel sans problémes les données de la base de données so nt lues
et
> >>>>>> affichés dans le grid.
> >>>>>> mais si je n'ai pas de point d'arret, tout le code est executé et a
la
> >>>>>> fin excel crashe (entre "Set rstRecordset = Nothing" et "End S ub"
> >>>>>> d'aprés quelques debug.print que j'ai mis)
> >>>>>> Quelqu'un saurait pourquoi ?
Salut Gilbert,
Oui, j'ai mis des doevents avant, malheureusement ça apporte plus de
problémes que ça en resoud car ADO etant asynchrone les methodes se
melangent et ça crée un gros crash d'excel aussi.
je crois que ma seule solution est de commencer a gérer les ADO Events
mais avec VBA je ne sais pas si c'est possible. Une autre solution
serait d'utiliser ADO en mode synchrone, chose que je ne sais pas
encore comment faire car par defaut les objects Connection et
Recordset de ADO sont asynchrones.
encore une poignée de cheveux en moins...
Salutations
On 28 mar, 17:38, "Gilbert" wrote:Bonjour
As-tu essayé de rajouter un Doevents avant les
Set cnnConn = Nothing
Set rstRecordset = Nothing
--
Cordialement,
Gilbert
"altarboy" a écrit dans le message denews:
Salut
Effectivement, ça a l'air plus logique, malheureusement ça ne change
rien. ça crash toujours quand je set les variables = Nothing.
De quoi m'arracher les cheveux. Heureusement que j'en ai plus.
On 28 mar, 15:45, isabelle wrote:bonjour,
oups desolé , la correction est :
While état1 <> adStateClose
état1 = rstRecordset.State
Wend
While état2 <> adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :si je le mets la :
...If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
While état1 = adStateClosed
état1 = rstRecordset.State
Wend
While état2 = adStateClosed
état2 = cnnConn.State
Wend'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
ben une fois sur deux ça reste dans la boucle car le state est deja
closed
On 28 mar, 14:49, isabelle wrote:Salut altarboy,
juste avant
Set cnnConn = Nothing
Set rstRecordset = Nothing
isabelle
altarboy a écrit :Salut Isabelle,
Je ne vois pas trop ou mettre ces deux boucles.
On 27 mar, 19:17, isabelle wrote:bonjour,
essai en y ajoutant une boucle :
While état1 = adStateClose
état1 = rstRecordset.State
Wend
While état2 = adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :Petite précision :
Si j'enlève du code la partie suivante tout fonctionne sans
problèmes :
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
Normalement on est pas sensés libérer les variables/objets une fois
qu'on a plus besoin ?
On 27 mar, 17:23, seliana wrote:Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label
maisqui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues
etaffichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a
lafin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
Salut Gilbert,
Oui, j'ai mis des doevents avant, malheureusement ça apporte plus de
problémes que ça en resoud car ADO etant asynchrone les methodes se
melangent et ça crée un gros crash d'excel aussi.
je crois que ma seule solution est de commencer a gérer les ADO Events
mais avec VBA je ne sais pas si c'est possible. Une autre solution
serait d'utiliser ADO en mode synchrone, chose que je ne sais pas
encore comment faire car par defaut les objects Connection et
Recordset de ADO sont asynchrones.
encore une poignée de cheveux en moins...
Salutations
On 28 mar, 17:38, "Gilbert" <ZZZgilbert...@NOSPAMlaposte.net> wrote:
Bonjour
As-tu essayé de rajouter un Doevents avant les
Set cnnConn = Nothing
Set rstRecordset = Nothing
--
Cordialement,
Gilbert
"altarboy" <altarbo...@gmail.com> a écrit dans le message denews:74607e49-31bd-4f9a-b7a2-dbc21c900d9e@f19g2000yqo.googlegroups.com...
Salut
Effectivement, ça a l'air plus logique, malheureusement ça ne change
rien. ça crash toujours quand je set les variables = Nothing.
De quoi m'arracher les cheveux. Heureusement que j'en ai plus.
On 28 mar, 15:45, isabelle <i@v> wrote:
bonjour,
oups desolé , la correction est :
While état1 <> adStateClose
état1 = rstRecordset.State
Wend
While état2 <> adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
si je le mets la :
...
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
While état1 = adStateClosed
état1 = rstRecordset.State
Wend
While état2 = adStateClosed
état2 = cnnConn.State
Wend
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
ben une fois sur deux ça reste dans la boucle car le state est deja
closed
On 28 mar, 14:49, isabelle <i@v> wrote:
Salut altarboy,
juste avant
Set cnnConn = Nothing
Set rstRecordset = Nothing
isabelle
altarboy a écrit :
Salut Isabelle,
Je ne vois pas trop ou mettre ces deux boucles.
On 27 mar, 19:17, isabelle <i@v> wrote:
bonjour,
essai en y ajoutant une boucle :
While état1 = adStateClose
état1 = rstRecordset.State
Wend
While état2 = adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :
Petite précision :
Si j'enlève du code la partie suivante tout fonctionne sans
problèmes :
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
Normalement on est pas sensés libérer les variables/objets une fois
qu'on a plus besoin ?
On 27 mar, 17:23, seliana <altarbo...@gmail.com> wrote:
Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label
mais
qui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues
et
affichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a
la
fin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?
Salut Gilbert,
Oui, j'ai mis des doevents avant, malheureusement ça apporte plus de
problémes que ça en resoud car ADO etant asynchrone les methodes se
melangent et ça crée un gros crash d'excel aussi.
je crois que ma seule solution est de commencer a gérer les ADO Events
mais avec VBA je ne sais pas si c'est possible. Une autre solution
serait d'utiliser ADO en mode synchrone, chose que je ne sais pas
encore comment faire car par defaut les objects Connection et
Recordset de ADO sont asynchrones.
encore une poignée de cheveux en moins...
Salutations
On 28 mar, 17:38, "Gilbert" wrote:Bonjour
As-tu essayé de rajouter un Doevents avant les
Set cnnConn = Nothing
Set rstRecordset = Nothing
--
Cordialement,
Gilbert
"altarboy" a écrit dans le message denews:
Salut
Effectivement, ça a l'air plus logique, malheureusement ça ne change
rien. ça crash toujours quand je set les variables = Nothing.
De quoi m'arracher les cheveux. Heureusement que j'en ai plus.
On 28 mar, 15:45, isabelle wrote:bonjour,
oups desolé , la correction est :
While état1 <> adStateClose
état1 = rstRecordset.State
Wend
While état2 <> adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :si je le mets la :
...If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
While état1 = adStateClosed
état1 = rstRecordset.State
Wend
While état2 = adStateClosed
état2 = cnnConn.State
Wend'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
ben une fois sur deux ça reste dans la boucle car le state est deja
closed
On 28 mar, 14:49, isabelle wrote:Salut altarboy,
juste avant
Set cnnConn = Nothing
Set rstRecordset = Nothing
isabelle
altarboy a écrit :Salut Isabelle,
Je ne vois pas trop ou mettre ces deux boucles.
On 27 mar, 19:17, isabelle wrote:bonjour,
essai en y ajoutant une boucle :
While état1 = adStateClose
état1 = rstRecordset.State
Wend
While état2 = adStateClose
état2 = cnnConn.State
Wend
isabelle
altarboy a écrit :Petite précision :
Si j'enlève du code la partie suivante tout fonctionne sans
problèmes :
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
Alors soit je deviens trop vieux soit ..... je deviens trop vieux.
Normalement on est pas sensés libérer les variables/objets une fois
qu'on a plus besoin ?
On 27 mar, 17:23, seliana wrote:Bonjour microsoft.public.fr.excel,
Comment se fait il que le code ci dessous fasse crasher Excel quand
exécuté sans interruption alors que s'il est exécuté pas à pas tout
fonctionne sans problème.
j'ai sur ma feuille :
calAgent - objet calendrier (microsoft calendar control 11.0)
VSFlexGrid1 - voila :) VS Flex Grid v7
ComboBox1 - objet combobox
ainsi que un bouton (CommandButton1) et quelques textbox et label
maisqui ne sont pas encore utilisés
Voici le code en question.
--------------------------------------------
Option Explicit
'declaration de variables
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.recordSet
Dim tempQuery As String
Private Sub CommandButton1_Click()
'definition de variables
Set cnnConn = New ADODB.Connection
Set rstRecordset = New ADODB.recordSet
tempQuery = "SELECT tAgents.AgentName, tAgents.isTemp,
tAgents.percentage, tBEELoginLogout.entryDate,
tBEELoginLogout.entryLoginCET, tBEELoginLogout.entryLogoutCET,
tBEELoginLogout.isValid FROM tAgents INNER JOIN tBEELoginLogout ON
tAgents.AgentName = tBEELoginLogout.ptrAgentName WHERE
(((tAgents.AgentName) Like """ & "%" & frmPointage.ComboBox1.value
tempQuery = tempQuery & "%" & """) AND ((tBEELoginLogout.entryDate)
=#" & calAgent.Month & "/" & calAgent.Day & "/" & calAgent.Year &
"#));"
'Vérifie que la connexion est bien fermée
If cnnConn.State = adStateOpen Then cnnConn.Close
'Etabli la connection
cnnConn.ConnectionString = CAppConnectionString
cnnConn.Open CAppPathTodB
'Attente que la connexion soit établie
While (cnnConn.State = adStateConnecting)
DoEvents
Wend
'vérifie que le recordset est bien fermée
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'ouvre le recordset
rstRecordset.Open tempQuery, cnnConn
'transpose recordset dans grid
Set VSFlexGrid1.DataSource = rstRecordset
'si recordset encore ouvert alors le ferme
If rstRecordset.State = adStateOpen Then rstRecordset.Close
'si connection encore ouverte alors la ferme
If cnnConn.State = adStateOpen Then cnnConn.Close
'libere objets
Set cnnConn = Nothing
Set rstRecordset = Nothing
End Sub
--------------------------------------------
ainsi que quelques constantes définies dans un module
--------------------------------------------
Public Const AppVersion = "0.2.9"
Public Const AppInDevMode = True
Public Const CAppPathTodB = "U:_devfifomain.mdb"
Public Const CAppConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;"
--------------------------------------------
Si je clique sur CommandButton1 et que j'ai un point d'arret sur le
debut du CommandButton1_Click() et qu'ensuite j'execute pas à pas.
nickel sans problémes les données de la base de données sont lues
etaffichés dans le grid.
mais si je n'ai pas de point d'arret, tout le code est executé et a
lafin excel crashe (entre "Set rstRecordset = Nothing" et "End Sub"
d'aprés quelques debug.print que j'ai mis)
Quelqu'un saurait pourquoi ?