Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
François Picalausa
"Alain MENARD" a écrit dans le message de news:3fb65092$0$27031$
Re bonjour
Avant de supprimer un champ, je voudrais savoir s'il existe.
Merci par avance
Bonjour/soir,
voicci deux solutions qui semblent fonctionner: Option Explicit
Private Sub Form_Load()
Dim cat As ADOX.Catalog, myCol As ADOX.Column
Set cat = New ADOX.Catalog
' Connexion à la base de donnée cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:Documents and SettingsFrançois PicalausaMes documentsMy websBrinksterarticles.mdb"
' Suppression du champ On Error Resume Next Set myCol = cat.Tables("news").Columns("Toto") Select Case Err.Number Case 0 MsgBox "Le champ Toto existe!" Case 3265 MsgBox "Le champ Toto n'existe pas!" Case Else MsgBox "Une erreur innatendue s'est produite !" End Select Err.Clear On Error GoTo 0
For Each myCol In cat.Tables("news").Columns If myCol.Name = "PubDate" Then MsgBox "Le champ PubDate existe!" Exit For End If Next myCol
Set myCol = Nothing Set cat = Nothing End Sub
Toutefois, n'étant absolument pas expert dans le domaine, il est possible que ces codes soient erronnés. J'espère que ça pourra aider en attendant mieux ;-)
"Alain MENARD" <philatelix@free.fr> a écrit dans le message de
news:3fb65092$0$27031$626a54ce@news.free.fr
Re bonjour
Avant de supprimer un champ, je voudrais savoir s'il existe.
Merci par avance
Bonjour/soir,
voicci deux solutions qui semblent fonctionner:
Option Explicit
Private Sub Form_Load()
Dim cat As ADOX.Catalog, myCol As ADOX.Column
Set cat = New ADOX.Catalog
' Connexion à la base de donnée
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=F:Documents and SettingsFrançois PicalausaMes documentsMy
websBrinksterarticles.mdb"
' Suppression du champ
On Error Resume Next
Set myCol = cat.Tables("news").Columns("Toto")
Select Case Err.Number
Case 0
MsgBox "Le champ Toto existe!"
Case 3265
MsgBox "Le champ Toto n'existe pas!"
Case Else
MsgBox "Une erreur innatendue s'est produite !"
End Select
Err.Clear
On Error GoTo 0
For Each myCol In cat.Tables("news").Columns
If myCol.Name = "PubDate" Then
MsgBox "Le champ PubDate existe!"
Exit For
End If
Next myCol
Set myCol = Nothing
Set cat = Nothing
End Sub
Toutefois, n'étant absolument pas expert dans le domaine, il est possible
que ces codes soient erronnés. J'espère que ça pourra aider en attendant
mieux ;-)
"Alain MENARD" a écrit dans le message de news:3fb65092$0$27031$
Re bonjour
Avant de supprimer un champ, je voudrais savoir s'il existe.
Merci par avance
Bonjour/soir,
voicci deux solutions qui semblent fonctionner: Option Explicit
Private Sub Form_Load()
Dim cat As ADOX.Catalog, myCol As ADOX.Column
Set cat = New ADOX.Catalog
' Connexion à la base de donnée cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:Documents and SettingsFrançois PicalausaMes documentsMy websBrinksterarticles.mdb"
' Suppression du champ On Error Resume Next Set myCol = cat.Tables("news").Columns("Toto") Select Case Err.Number Case 0 MsgBox "Le champ Toto existe!" Case 3265 MsgBox "Le champ Toto n'existe pas!" Case Else MsgBox "Une erreur innatendue s'est produite !" End Select Err.Clear On Error GoTo 0
For Each myCol In cat.Tables("news").Columns If myCol.Name = "PubDate" Then MsgBox "Le champ PubDate existe!" Exit For End If Next myCol
Set myCol = Nothing Set cat = Nothing End Sub
Toutefois, n'étant absolument pas expert dans le domaine, il est possible que ces codes soient erronnés. J'espère que ça pourra aider en attendant mieux ;-)