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

delete all table et import new table

13 réponses
Avatar
FTH
Bonjour,

avec une de mes appli, je dois régulièrement deleter toutes les tables et re
importer les tables d'une appli mise à jour.
En generale, je fais ça à la main.. mais la, je fatigue.
Je test avec les macros mais je n'arrive à aucun résultat..

Auriez vous une piste pou moi,

d'avance merci

Frédéirc

3 réponses

1 2
Avatar
FTH
Eric,

ta petite proc fonctionne bien.
j'ai juste un pepin:
il y a une table liée à un serveur sql. ça pante quand elle doit l'importée.
comment serait il possible de ne pas prendre les tables liées?
d'avance mrci

Frédéric

"Eric" wrote in message
news:%
Pas vraiment, la bd est partagée ?

Sinon pour tout virer et importer, quelque chose comme:

Public Function zz()
' Charger la référence Microsoft DAO 3.x
Dim t As TableDef, bd2 As Database, LaBase As String
For Each t In CurrentDb.TableDefs
If Left(t.Name, 4) <> "MSys" Then
CurrentDb.TableDefs.Delete t.Name
End If
Next t
'Adapter le chemin et le nom de la bd
LaBase = CurrentProject.Path & "bd1.mdb"
Set bd2 = Workspaces(0).OpenDatabase(LaBase)
For Each t In bd2.TableDefs
If Left(t.Name, 4) <> "MSys" Then
DoCmd.TransferDatabase acImport, "Microsoft Access", _
LaBase, acTable, t.Name, t.Name
End If
Next t
bd2.Close
Set bd2 = Nothing
RefreshDatabaseWindow
End Function

et sur l'évènement clic d'un bouton : =zz()

Eric,

en appliquant ta solution, j'ai une erreur:
the database engine could not lock table 'MsysAccessStorage' because it
is already in use by another persons or process..

Une idée?

Merci

Frédéric



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



Avatar
Eric
Bonjour,

Donc ça revient à ne pas la supprimer dans la 1ere base ni à la
réimporter à partir de la 2ème base.

Je tenterai quelque chose comme :

Dans la partie suppression des tables et importation , modifier les If
ainsi:

If Left(t.Name, 4) <> "MSys" Then and t.Attributes <> dbAttachedODBC then

Sans garantie ;-)

Eric,

ta petite proc fonctionne bien.
j'ai juste un pepin:
il y a une table liée à un serveur sql. ça pante quand elle doit
l'importée.
comment serait il possible de ne pas prendre les tables liées?
d'avance mrci

Frédéric


"Eric" wrote in message
news:%
Pas vraiment, la bd est partagée ?

Sinon pour tout virer et importer, quelque chose comme:

Public Function zz()
' Charger la référence Microsoft DAO 3.x
Dim t As TableDef, bd2 As Database, LaBase As String
For Each t In CurrentDb.TableDefs
If Left(t.Name, 4) <> "MSys" Then
CurrentDb.TableDefs.Delete t.Name
End If
Next t
'Adapter le chemin et le nom de la bd
LaBase = CurrentProject.Path & "bd1.mdb"
Set bd2 = Workspaces(0).OpenDatabase(LaBase)
For Each t In bd2.TableDefs
If Left(t.Name, 4) <> "MSys" Then
DoCmd.TransferDatabase acImport, "Microsoft Access", _
LaBase, acTable, t.Name, t.Name
End If
Next t
bd2.Close
Set bd2 = Nothing
RefreshDatabaseWindow
End Function

et sur l'évènement clic d'un bouton : =zz()

Eric,

en appliquant ta solution, j'ai une erreur:
the database engine could not lock table 'MsysAccessStorage' because
it is already in use by another persons or process..

Une idée?

Merci

Frédéric



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




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



Avatar
Eric
.../...

Y a un Then de trop, sacré copié-collé.

If Left(t.Name, 4) <> "MSys" and t.Attributes <> dbAttachedODBC then

...
If Left(t.Name, 4) <> "MSys" Then and t.Attributes <> dbAttachedODBC then



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

1 2