Bonjour,

Je suis en stage .Je suis débutant dans VBA et access. Je rencontre le problème suivant :
On est sur un réseau partagé on a une base de données appelée « ROCPTA ». Cette base contient un code VBA (détails en bas) qui importe des fichiers Excel (ces fichiers Excel sont en format Excel csv sous un emplacement réseau).
Ces fichiers Excel ont été modifiés récemment par l’ajout de 3 colonnes. On est passé de 25 champs à 28.lors de l’exécution de la macro Access ( qui contient le code VBA de la base ROCPTA) l’importation des fichiers ne se fait pas correctement. En effet les tables dans ROCPTA ont toujours le même nombre de champ 25. Access ne tient pas compte de la modification (les 3 champs supplémentaires).

Comment intégrer dans mes tables de la base ROCPTA , ces nouveaux champs ?

Pourriez-vous m'aider svp ?


le code VBA


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Function F_Utilitaires_DonneDate(target_id) As Date
' ---------------------------------------------------------
' - Date : 21/10/00
' - Auteur : N. FERRASSE
' - Commentaire : Gestion des dates paramètres
' ---------------------------------------------------------
 
tb0 = "Date"
Dim BDD As Database
Set BDD = CurrentDb
Dim RS As Recordset
 
a = "SELECT DISTINCTROW [" & tb0 & "].date "
b = "FROM [" & tb0 & "]"
c = "WHERE ([" & tb0 & "].target = '" & target_id & "')"
 
z = a & b & c
 
' Début du traitement
' Selectionne la date demandée dans la table Init_Param
Set RS = BDD.OpenRecordset(z, dbOpenSnapshot)
F_Utilitaires_DonneDate = RS!Date
 
End Function
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Function ImportROCPTA()
Datesel = F_Utilitaires_DonneDate("Date_jour")
DatRes = Mid(Datesel, 7, 4) & Mid(Datesel, 4, 2) & Mid(Datesel, 1, 2)
MsgBox (DatRes)
DoCmd.TransferText acImportDelim, "ROCPTA", "Base 10260", _
"\\Umilp-p2.cdm.cm-cic.fr\CIC-Ctrlint$\Controle_des_resultats\Rapprochement_de_resultat\Reporting_2014\Report_mensuel\Rappro ROCPTA\Fichiers ROCPTA\ROCPTADetailc_M_" & DatRes & "_10260_CPTA.csv"
DoCmd.TransferText acImportDelim, "ROCPTA", "Base 10117", _
"\\Umilp-p2.cdm.cm-cic.fr\CIC-Ctrlint$\Controle_des_resultats\Rapprochement_de_resultat\Reporting_2014\Report_mensuel\Rappro ROCPTA\Fichiers ROCPTA\ROCPTADetailc_M_" & DatRes & "_10117_CPTA.csv"
DoCmd.TransferText acImportDelim, "ROCPTA", "Base 10002", _
"\\Umilp-p2.cdm.cm-cic.fr\CIC-Ctrlint$\Controle_des_resultats\Rapprochement_de_resultat\Reporting_2014\Report_mensuel\Rappro ROCPTA\Fichiers ROCPTA\ROCPTADetailc_M_" & DatRes & "_10002_CPTA.csv"
DoCmd.TransferText acImportDelim, "ROCPTA", "Base 10115", _
"\\Umilp-p2.cdm.cm-cic.fr\CIC-Ctrlint$\Controle_des_resultats\Rapprochement_de_resultat\Reporting_2014\Report_mensuel\Rappro ROCPTA\Fichiers ROCPTA\ROCPTADetailc_M_" & DatRes & "_10115_CPTA.csv"
DoCmd.TransferText acImportDelim, "ROCPTA", "Base TRESO", _
"\\Umilp-p2.cdm.cm-cic.fr\CIC-Ctrlint$\Controle_des_resultats\Rapprochement_de_resultat\Reporting_2014\Report_mensuel\Rappro ROCPTA\Fichiers ROCPTA\ROCPTADetailc_M_" & DatRes & "_TRESO_CPTA.csv"
DoCmd.TransferText acImportDelim, "ROCPTA", "Base TAUX", _
"\\Umilp-p2.cdm.cm-cic.fr\CIC-Ctrlint$\Controle_des_resultats\Rapprochement_de_resultat\Reporting_2014\Report_mensuel\Rappro ROCPTA\Fichiers ROCPTA\ROCPTADetailc_M_" & DatRes & "_TAUX_CPTA.csv"
DoCmd.TransferText acImportDelim, "ROCPTA", "Base LA", _
"\\Umilp-p2.cdm.cm-cic.fr\CIC-Ctrlint$\Controle_des_resultats\Rapprochement_de_resultat\Reporting_2014\Report_mensuel\Rappro ROCPTA\Fichiers ROCPTA\ROCPTADetailc_M_" & DatRes & "_LA_CPTA.csv"
DoCmd.TransferText acImportDelim, "ROCPTA", "Base ACTION", _
"\\Umilp-p2.cdm.cm-cic.fr\CIC-Ctrlint$\Controle_des_resultats\Rapprochement_de_resultat\Reporting_2014\Report_mensuel\Rappro ROCPTA\Fichiers ROCPTA\ROCPTADetailc_M_" & DatRes & "_ACT_CPTA.csv"
DoCmd.TransferText acImportDelim, "ROCPTA", "Base LS CIGOGNE", _
"\\Umilp-p2.cdm.cm-cic.fr\CIC-Ctrlint$\Controle_des_resultats\Rapprochement_de_resultat\Reporting_2014\Report_mensuel\Rappro ROCPTA\Fichiers ROCPTA\ROCPTADetailc_M_" & DatRes & "_LS_CI_CPTA.csv"
 
 
End Function
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Function ExportROCPTAInput()
Datesel = F_Utilitaires_DonneDate("Date_jour")
  datinput = Mid(Datesel, 7, 4)
 MsgBox datinput
 tb0 = "Fichier Input"
 
' Envoie sous Excel dans Input'
 
 DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, tb0, _
"\\Umilp-p2.cdm.cm-cic.fr\cic-ctrlint$\Controle_des_resultats\Rapprochement_de_resultat\Reporting_" & datinput & "\Report_mensuel\Input\ROCPTA CIC"
 
 
 
End Function