Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

vérifier la présence d'une table

4 réponses
Avatar
macgiver
Est-il possible, par vba, de vérifier la présence d'une table, si elle est
présente alors je fais une application sinon je fais autre chose?

merci

4 réponses

Avatar
Eric
Bonsoir,

Par exemple, avec ceci:

Function fExisteTable(NomTable As String) As Boolean
Dim bd As Database, t As TableDef
Set bd = CurrentDb
For Each t In bd.TableDefs
If t.Name = NomTable Then
fExisteTable = True
Exit For
End If
Next t
Set bd = Nothing
End Function



Est-il possible, par vba, de vérifier la présence d'une table, si elle est
présente alors je fais une application sinon je fais autre chose?

merci


--
A+
Eric
http://www.mpfa.info/
Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr

Avatar
Bruno Frisque
Bonsoir,

Fort bien !
Mais si la table n'existe pas ?
Comment la créer ?
A partir de MaTableStructure par exemple.
MsgBox : "votre nom svp. ... et puis :

Do Cmd copy MaTableStructure vers NewTable ??

Bien à vous


"Eric" wrote in message
news:%
Bonsoir,

Par exemple, avec ceci:

Function fExisteTable(NomTable As String) As Boolean
Dim bd As Database, t As TableDef
Set bd = CurrentDb
For Each t In bd.TableDefs
If t.Name = NomTable Then
fExisteTable = True
Exit For
End If
Next t
Set bd = Nothing
End Function



Est-il possible, par vba, de vérifier la présence d'une table, si elle
est présente alors je fais une application sinon je fais autre chose?

merci


--
A+
Eric
http://www.mpfa.info/
Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr



Avatar
Eric
Bonsoir,

Supposons que tu testes la présence de la table tBruno, tu n'as donc pas
besoin de redemander le nom de la table à créer si elle n'existe pas. Je
ferai quelque chose comme ceci en supposant que la table
MaTableStructure est dans la base courante :

Sub zz()
If Not fExisteTable("tBruno") Then
DoCmd.TransferDatabase acImport, "Microsoft Access", _
CurrentProject.FullName, acTable, _
"MaTableStructure", "tBruno", True
Else
' l'autre traitement
End If
End Sub

Bonsoir,

Fort bien !
Mais si la table n'existe pas ?
Comment la créer ?
A partir de MaTableStructure par exemple.
MsgBox : "votre nom svp. ... et puis :

Do Cmd copy MaTableStructure vers NewTable ??

Bien à vous


"Eric" wrote in message
news:%
Bonsoir,

Par exemple, avec ceci:

Function fExisteTable(NomTable As String) As Boolean
Dim bd As Database, t As TableDef
Set bd = CurrentDb
For Each t In bd.TableDefs
If t.Name = NomTable Then
fExisteTable = True
Exit For
End If
Next t
Set bd = Nothing
End Function



Est-il possible, par vba, de vérifier la présence d'une table, si elle
est présente alors je fais une application sinon je fais autre chose?

merci
--

A+
Eric
http://www.mpfa.info/" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://www.mpfa.info/
Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://groups.google.fr/group/microsoft.public.fr.access?hl=fr





--
A+
Eric
http://www.mpfa.info/" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://www.mpfa.info/
Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://groups.google.fr/group/microsoft.public.fr.access?hl=fr



Avatar
Bruno Frisque
Tout grand merci Eric !


"Eric" wrote in message
news:e$KVT$
Bonsoir,

Supposons que tu testes la présence de la table tBruno, tu n'as donc pas
besoin de redemander le nom de la table à créer si elle n'existe pas. Je
ferai quelque chose comme ceci en supposant que la table MaTableStructure
est dans la base courante :

Sub zz()
If Not fExisteTable("tBruno") Then
DoCmd.TransferDatabase acImport, "Microsoft Access", _
CurrentProject.FullName, acTable, _
"MaTableStructure", "tBruno", True
Else
' l'autre traitement
End If
End Sub

Bonsoir,

Fort bien !
Mais si la table n'existe pas ?
Comment la créer ?
A partir de MaTableStructure par exemple.
MsgBox : "votre nom svp. ... et puis :

Do Cmd copy MaTableStructure vers NewTable ??

Bien à vous


"Eric" wrote in message
news:%
Bonsoir,

Par exemple, avec ceci:

Function fExisteTable(NomTable As String) As Boolean
Dim bd As Database, t As TableDef
Set bd = CurrentDb
For Each t In bd.TableDefs
If t.Name = NomTable Then
fExisteTable = True
Exit For
End If
Next t
Set bd = Nothing
End Function



Est-il possible, par vba, de vérifier la présence d'une table, si elle
est présente alors je fais une application sinon je fais autre chose?

merci
--

A+
Eric
http://www.mpfa.info/" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://www.mpfa.info/
Archives :
http://groups.google.fr/group/microsoft.public.fr.access?hl=fr" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://groups.google.fr/group/microsoft.public.fr.access?hl=fr





--
A+
Eric
http://www.mpfa.info/" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://www.mpfa.info/
Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://groups.google.fr/group/microsoft.public.fr.access?hl=fr