Bonjour,
Dans un code VB, j'ai cette requête qui fonctionne
Afin de pouvoir itérer sur cette requête et faire évoluer la construction de la requête en fonction de l'évolution du nom des champs, Je voudrai intégrer des variables dans la requête. J'ai donc testé ceci
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 strSql = "INSERT INTO Devis (NumDevis,IdProjetSPC,Taille,Ind_BTW,Ind_BTX,Ind_BTZ,Type,Domaine,Action,Indicateur,Nombre ) VALUES (" & _ "'" & Me.NumDevis & "'" & "," & _ "'" & Me.idProjet & "'" & "," & _ "'" & Me.Taille & "'" & "," & _ Me![Onglet Projet].Form!BTW & "," & _ Me![Onglet Projet].Form!BTX & "," & _ Me![Onglet Projet].Form!BTZ & "," & _ "'" & Me![Onglet Projet].Form!TypeDevis & "'" & "," & _ "'" & DomAct & "'" & "," & _ "'" & Action & "'" & "," & _ Me![Onglet Projet].Form![Onglet-Architecture].Form![IND-ASR] & "," & _ Me![Onglet Projet].Form![Onglet-Architecture].Form![NB-ASR] & _ ");" dbBdeD.Execute strSql, dbFailOnError
Mon problème est que, dans les paramètres IND et NB, il récupère la chaine de caractère et non pas la valeur du champ correspondant.
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 DomAct = "AA" Action = "ASR" IND = "Me![Onglet Projet].Form![Onglet-Architecture].Form![IND-" & Action & "]" NB = "Me![Onglet Projet].Form![Onglet-Architecture].Form![NB-" & Action & "]" strSql = "INSERT INTO Devis (NumDevis,IdProjetSPC,Taille,Ind_BTW,Ind_BTX,Ind_BTZ,Type,Domaine,Action,Indicateur,Nombre ) VALUES (" & _ "'" & Me.NumDevis & "'" & "," & _ "'" & Me.idProjet & "'" & "," & _ "'" & Me.Taille & "'" & "," & _ Me![Onglet Projet].Form!BTW & "," & _ Me![Onglet Projet].Form!BTX & "," & _ Me![Onglet Projet].Form!BTZ & "," & _ "'" & Me![Onglet Projet].Form!TypeDevis & "'" & "," & _ "'" & DomAct & "'" & "," & _ "'" & Action & "'" & "," & _ IND & "," & _ NB & _ ");" dbBdeD.Execute strSql, dbFailOnError
Comment faire pour récupérer cette valeur ?
Merci d'avance pour votre aide.
Partager