je ne comprends la fonction ci-dessous m'affiche le message d'erreur sur la
ligne : cat.ActiveConnection = ADOcn : "Variable objet ou variable bloc with
non définie"
Public Function TableExists(cat As ADOX.Catalog, TableName As String) As
Boolean
cheminTable = cheminBase & BaseName
'Vérifie que la connexion est bien fermée
If ADOcn.state = adStateOpen Then
ADOcn.Close
End If
Set ADOcn = Nothing
'creation d'une connection sur la base
With ADOcn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & cheminTable
.CursorLocation = adUseClient
.Open
End With
' Enumère toutes les tables du catalogue
cat.ActiveConnection = ADOcn
For Each tbl In cat.Tables
If tbl.Name = TableName Then 'TableName=table recherchée
TableExists = True
Exit For
End If
Next
If TableExists = False Then
Call CreerTable(cat, TableName)
End If
Set tbl = Nothing
End Function
Et pourtant mes variables sont définies :
Public ADOcn As New ADODB.Connection
Public cat As New ADOX.Catalog
'creation d'une connection sur la base With ADOcn .Provider = "Microsoft.Jet.OLEDB.4.0" .ConnectionString = "Data Source=" & cheminTable .CursorLocation = adUseClient .Open End With
'creation d'une connection sur la base
With ADOcn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & cheminTable
.CursorLocation = adUseClient
.Open
End With
'creation d'une connection sur la base With ADOcn .Provider = "Microsoft.Jet.OLEDB.4.0" .ConnectionString = "Data Source=" & cheminTable .CursorLocation = adUseClient .Open End With