OVH Cloud OVH Cloud

Verifier l'existence d'une table

1 réponse
Avatar
A l'ouverture de mon formulaire je teste l'existence d'une=20
table temporaire pour savoir si je dois la cr=E9er ou non.

Comment ce test est il possible?
Merci

1 réponse

Avatar
Raymond
Bonjour.

Plusieurs solutions:
1-
Private Sub Commande0_Click()
On Error GoTo nexistepas
If CurrentData.AllTables("table1").Name = "table1" Then MsgBox "table
existe"
Exit Sub
nexistepas:
MsgBox "n'existe pas"
End Sub

2-
Private Sub Commande0_Click()
On Error GoTo nexistepas
Dim Tbl As DAO.TableDef
Set Tbl = CurrentDb.TableDefs("table1")
MsgBox "table existe"
Set Tbl = Nothing
Exit Sub
nexistepas:
MsgBox "n'existe pas"
End Sub

3-
Private Sub Commande0_Click()
On Error GoTo nexistepas
Dim Tbl As DAO.Recordset
Set Tbl = CurrentDb.OpenRecordset("table1")
MsgBox "table existe"
Set Tbl = Nothing
Exit Sub
nexistepas:
MsgBox "n'existe pas"
End Sub

--
@+
Raymond Access MVP.
http://access.seneque.free.fr/
http://access2003.free.fr/
http://users.skynet.be/mpfa/charte.htm pour une meilleure
efficacité de tes interventions sur MPFA.


a écrit dans le message de
news:077b01c396e6$258b5a80$
A l'ouverture de mon formulaire je teste l'existence d'une
table temporaire pour savoir si je dois la créer ou non.

Comment ce test est il possible?
Merci