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

d'une table à l'autre

28 réponses
Avatar
fth
Bonjour,

J'ai un petit probleme avec un bout de code qui fonctionne pourtant dans une
autre de mes appli....

Quelqu'un pour me faire une correction?

d'avance merci

ci joint, le code en question:

Private Sub BtValider_Click()

'si le record "idrb" de la table "running_business" n'existe pas dans la
table "BC"
'ajouter le record; si elle existe, mettre à jour le record dans la table
"BC" pour les
'lignes de "running_business" ou ("rbstatus" = "g"). pour les autres lignes,
ne rien faire ( ou peut etre un msgbox)

If IsNull(DLookup("IDRB", "BC", "idrb=" & IDRB)) Then

DoCmd.RunSQL "INSERT INTO BC ( IDRB, IDcompany, IDcontact, RBstart, RBref,
RBstatus," & _
"RBforecastdate, RBcatprod, RbQuArt, RBTotalHw, RBTotalOption,
RBTotalSolution, " & _
"RBclickvolume, RBclickprice, RBLenght, RBestimforecast, RBforecastCA,
RBdonestatus," & _
"RBcomment, RBdetail, RBTotPaHw, RBTotPaOption, RBTotPaSolution,
RBTotPAcopy, RBdone, " & _
"flag1 ) " & _
"SELECT running_business.IDRB, running_business.IDcompany,
running_business.IDcontact, " & _
"running_business.RBstart, running_business.RBref,
running_business.RBstatus," & _
"running_business.RBforecastdate, running_business.RBcatprod,
running_business.RbQuArt, " & _
"running_business.RBTotalHw, running_business.RBTotalOption,
running_business.RBTotalSolution, " & _
"running_business.RBclickvolume, running_business.RBclickprice,
running_business.RBLenght, " & _
"running_business.RBestimforecast, running_business.RBforecastCA,
running_business.RBdonestatus, " & _
"running_business.RBcomment, running_business.RBdetail,
running_business.RBTotPaHw, " & _
"running_business.RBTotPaOption, running_business.RBTotPaSolution,
running_business.RBTotPAcopy, " & _
"running_business.RBdone, running_business.flag1, " & _
"FROM running_business WHERE (running_business.IDRB = IDRB)AND
(running_business.rbstatus = 'G');"

Else



If (DLookup("idrb", "BC", "idrb=" & IDRB)) Then

DoCmd.RunSQL "UPDATE BC INNER JOIN running_business ON BC.IDRB =
running_business.IDRB " & _
"SET BC.IDcompany = [running_business].[IDcompany], " & _
"BC.IDcontact = [running_business].[IDcontact], " & _
"BC.RBstart = [running_business].[RBstart], " & _
"BC.RBref = [running_business].[RBref], " & _
"BC.RBstatus = [running_business].[RBstatus], " & _
"BC.RBforecastdate = [running_business].[RBforecastdate], " & _
"BC.RBcatprod = [running_business].[RBcatprod], " & _
"BC.RbQuArt = [running_business].[RbQuArt], " & _
"BC.RBTotalHw = [running_business].[RBTotalHw], " & _
"BC.RBTotalOption = [running_business].[RBTotalOption], " & _
"BC.RBTotalSolution = [running_business].[RBTotalSolution], " & _
"BC.RBclickvolume = [running_business].[RBclickvolume]," & _
"BC.RBestimforecast = [running_business].[RBestimforecast], " & _
"BC.RBforecastCA = [running_business].[RBforecastCA], " & _
"BC.RBdonestatus = [running_business].[RBdonestatus], " & _
"BC.RBcomment = [running_business].[RBcomment], " & _
"BC.RBdetail = [running_business].[RBdetail], " & _
"BC.RBTotPaHw = [running_business].[RBTotPaHw], " & _
"BC.RBTotPaOption = [running_business].[RBTotPaOption], " & _
"BC.RBTotPaSolution = [running_business].[RBTotPaSolution], " & _
"BC.RBTotPAcopy = [running_business].[RBTotPAcopy], " & _
"BC.flag1 = [running_business].[flag1], " & _
"FROM running_business WHERE (running_business.IDRB = IDRB)AND
(running_business.rbstatus = 'G');"


End If
End If



End Sub

8 réponses

1 2 3
Avatar
Pierre CFI [mvp]
moi aussi, tu veux redonner ton code update qui coince, parce que qu'avec les 2 zozos je sais plus ou on en est, comme ils
pataugent, j'arrive (avec les assistantes)

--
Pierre CFI
MVP Microsoft Access
Mail : http://cerbermail.com/?z0SN8cN53B

Site pour bien commencer
http://users.skynet.be/mpfa/
Site perso
http://access.cfi.free.fr
"fth" a écrit dans le message de news:408e7a8a$0$21491$
" une douzaine de vahinées qui scrutent les news sur des écran plasma
70"....
Y en a qui savent réunir les bonne conditions de travail.....chtejure :-))
...

bon, ça y est, vous m'avez déconcentré avec vos histoires ...

NB: je parlais des écrans hein...

"Raymond [mvp]" wrote in message
news:
C'est pour ça que tu insistes pour venir travailler avec moi, mais tant
que

ta motivation ne sera pas uniquement tournée mpfa, je refuserais.

--
@+
Raymond Access MVP
http://access.seneque.free.fr/
http://access2003.free.fr/
http://users.skynet.be/mpfa/ pour débuter sur le forum


"Pierre CFI [mvp]" a écrit dans le message de
news:
oui, mais raymond il a pas beaucoup de mérite. Une douzaine
d'assistantes


(jeunes informaticiennes venues des iles) qui scructent
les news sur des écrans plasma 70 '' :o))

--
Pierre CFI










Avatar
fth
Salut Pierre,

apres les corrections, si rbstatus est différent (pas egal) à "G", il me met
qu'il met à jour 0 record, donc OK
si rbstatus = "G" il passe alors à la partie UPDATE et me donne comme
message

run-time error '3075'
Syntax error (missing operator) in query expression
'[running_business].[RBtotpasolution] FROM running_business'.

d'avance merci

Frederic

ci-dessous le code complet (INSERT et UPDATE)

Private Sub BtValider_Click()

'si le record "idrb" de la table "running_business" n'existe pas dans la
table "BC"
'ajouter le record; si elle existe, mettre à jour le record dans la table
"BC" pour les
'lignes de "running_business" ou "rbstatus" = "g"


If IsNull(DLookup("IDRB", "BC", "idrb=" & IDRB)) Then

DoCmd.RunSQL "INSERT INTO BC ( IDRB, IDcompany, IDcontact, RBstart,RBref,
RBstatus," & _
"RBforecastdate, RBcatprod, RbQuArt, RBTotalHw,
RBTotalOption,RBTotalSolution, " & _
"RBclickvolume, RBclickprice, RBLenght,
RBestimforecast,RBforecastCA," & _
"RBdonestatus,RBcomment, RBdetail, RBTotPaHw, RBTotPaOption,
RBTotPaSolution," & _
"RBTotPAcopy, RBdone,flag1) " & _
"SELECT running_business.IDRB,
running_business.IDcompany,running_business.IDcontact , " & _
"running_business.RBstart,
running_business.RBref,running_business.RBstatus , " & _
"running_business.RBforecastdate,
running_business.RBcatprod,running_business.RbQuArt , " & _
"running_business.RBTotalHw,
running_business.RBTotalOption,running_business.RBTotalSolution , " & _
"running_business.RBclickvolume,
running_business.RBclickprice,running_business.RBLenght , " & _
"running_business.RBestimforecast,
running_business.RBforecastCA,running_business.RBdonestatus , " & _
"running_business.RBcomment,
running_business.RBdetail,running_business.RBTotPaHw , " & _
"running_business.RBTotPaOption,
running_business.RBTotPaSolution,running_business.RBTotPAcopy, " & _
"running_business.RBdone, running_business.flag1 " & _
"FROM running_business WHERE (running_business.IDRB = " & IDRB & ") AND
(running_business.rbstatus = 'G');"


Else

'If (DLookup("idrb", "BC", "idrb=" & IDRB)) = IDRB Then

DoCmd.RunSQL "UPDATE BC INNER JOIN running_business ON BC.IDRB running_business.IDRB " & _
"SET BC.IDRB = [running_business].[IDRB], " & _
"BC.IDcompany = [running_business].[IDcompany], " & _
"BC.IDcontact = [running_business].[IDcontact], " & _
"BC.RBstart = [running_business].[RBstart], " & _
"BC.RBref = [running_business].[RBref], " & _
"BC.RBstatus = [running_business].[RBstatus], " & _
"BC.RBforecastdate = [running_business].[RBforecastdate], " & _
"BC.RBcatprod = [running_business].[RBcatprod], " & _
"BC.RbQuArt = [running_business].[RbQuArt], " & _
"BC.RBTotalHw = [running_business].[RBTotalHw], " & _
"BC.RBTotalOption = [running_business].[RBTotalOption], " & _
"BC.RBTotalSolution = [running_business].[RBTotalSolution], " & _
"BC.RBclickvolume = [running_business].[RBclickvolume], " & _
"BC.RBestimforecast = [running_business].[RBestimforecast], " & _
"BC.RBforecastCA = [running_business].[RBforecastCA], " & _
"BC.RBdonestatus = [running_business].[RBdonestatus], " & _
"BC.RBcomment = [running_business].[RBcomment], " & _
"BC.RBdetail = [running_business].[RBdetail], " & _
"BC.RBTotPaHw = [running_business].[RBTotPaHw], " & _
"BC.RBTotPaOption = [running_business].[RBTotPaOption], " & _
"BC.RBTotPaSolution = [running_business].[RBTotPaSolution] " & _
"FROM running_business WHERE (running_business.IDRB = " & IDRB & ")
AND (running_business.rbstatus = 'G');"


End If
"Pierre CFI [mvp]" wrote in message
news:%
moi aussi, tu veux redonner ton code update qui coince, parce que qu'avec
les 2 zozos je sais plus ou on en est, comme ils

pataugent, j'arrive (avec les assistantes)

--
Pierre CFI
MVP Microsoft Access
Mail : http://cerbermail.com/?z0SN8cN53B

Site pour bien commencer
http://users.skynet.be/mpfa/
Site perso
http://access.cfi.free.fr
"fth" a écrit dans le message de
news:408e7a8a$0$21491$

" une douzaine de vahinées qui scrutent les news sur des écran plasma
70"....
Y en a qui savent réunir les bonne conditions de travail.....chtejure
:-))


...

bon, ça y est, vous m'avez déconcentré avec vos histoires ...

NB: je parlais des écrans hein...

"Raymond [mvp]" wrote in message
news:
C'est pour ça que tu insistes pour venir travailler avec moi, mais
tant



que
ta motivation ne sera pas uniquement tournée mpfa, je refuserais.

--
@+
Raymond Access MVP
http://access.seneque.free.fr/
http://access2003.free.fr/
http://users.skynet.be/mpfa/ pour débuter sur le forum


"Pierre CFI [mvp]" a écrit dans le message
de



news:
oui, mais raymond il a pas beaucoup de mérite. Une douzaine
d'assistantes


(jeunes informaticiennes venues des iles) qui scructent
les news sur des écrans plasma 70 '' :o))

--
Pierre CFI














Avatar
Raymond [mvp]
relis mon dernier post: enlève le from.

--
@+
Raymond Access MVP
http://access.seneque.free.fr/
http://access2003.free.fr/
http://users.skynet.be/mpfa/ pour débuter sur le forum


"fth" a écrit dans le message de
news:408e7d47$0$21691$
Salut Pierre,

apres les corrections, si rbstatus est différent (pas egal) à "G", il me
met

qu'il met à jour 0 record, donc OK
si rbstatus = "G" il passe alors à la partie UPDATE et me donne comme
message

run-time error '3075'
Syntax error (missing operator) in query expression
'[running_business].[RBtotpasolution] FROM running_business'.

d'avance merci

Frederic


Avatar
fth
salut,

....Pfffff, je suis NUL !

merci, ça roule très bien maintenant!

merci à tous les trois

Frederic

"Raymond [mvp]" wrote in message
news:
dans une update il n'y a pas de from
supprimer FROM running_business
--
@+
Raymond Access MVP
http://access.seneque.free.fr/
http://access2003.free.fr/
http://users.skynet.be/mpfa/ pour débuter sur le forum


"fth" a écrit dans le message de
news:408e786e$0$21781$
oups, ça progresse
sans la virgule dans la partie INSERT, ça fonctionne (merci)

mais j'ai encore une erreur dans la partie UPDATE:

run-time error '3075'

Syntax error (missing operator) in query expression
'[running_business].[flag1] FROM running_business'

quand je laisse la virgule dans UPDATE, error, quand je l'enleve, j'ai
le


message d'erreur ci-dessus.....

kessako?

Frederic






Avatar
Pierre CFI [mvp]
a la fin de update le from est de trop
"FROM running_business WHERE (running_business.IDRB = " & IDRB & ")
AND (running_business.rbstatus = 'G');"



--
Pierre CFI
MVP Microsoft Access
Mail : http://cerbermail.com/?z0SN8cN53B

Site pour bien commencer
http://users.skynet.be/mpfa/
Site perso
http://access.cfi.free.fr
"fth" a écrit dans le message de news:408e7d47$0$21691$
Salut Pierre,

apres les corrections, si rbstatus est différent (pas egal) à "G", il me met
qu'il met à jour 0 record, donc OK
si rbstatus = "G" il passe alors à la partie UPDATE et me donne comme
message

run-time error '3075'
Syntax error (missing operator) in query expression
'[running_business].[RBtotpasolution] FROM running_business'.

d'avance merci

Frederic

ci-dessous le code complet (INSERT et UPDATE)

Private Sub BtValider_Click()

'si le record "idrb" de la table "running_business" n'existe pas dans la
table "BC"
'ajouter le record; si elle existe, mettre à jour le record dans la table
"BC" pour les
'lignes de "running_business" ou "rbstatus" = "g"


If IsNull(DLookup("IDRB", "BC", "idrb=" & IDRB)) Then

DoCmd.RunSQL "INSERT INTO BC ( IDRB, IDcompany, IDcontact, RBstart,RBref,
RBstatus," & _
"RBforecastdate, RBcatprod, RbQuArt, RBTotalHw,
RBTotalOption,RBTotalSolution, " & _
"RBclickvolume, RBclickprice, RBLenght,
RBestimforecast,RBforecastCA," & _
"RBdonestatus,RBcomment, RBdetail, RBTotPaHw, RBTotPaOption,
RBTotPaSolution," & _
"RBTotPAcopy, RBdone,flag1) " & _
"SELECT running_business.IDRB,
running_business.IDcompany,running_business.IDcontact , " & _
"running_business.RBstart,
running_business.RBref,running_business.RBstatus , " & _
"running_business.RBforecastdate,
running_business.RBcatprod,running_business.RbQuArt , " & _
"running_business.RBTotalHw,
running_business.RBTotalOption,running_business.RBTotalSolution , " & _
"running_business.RBclickvolume,
running_business.RBclickprice,running_business.RBLenght , " & _
"running_business.RBestimforecast,
running_business.RBforecastCA,running_business.RBdonestatus , " & _
"running_business.RBcomment,
running_business.RBdetail,running_business.RBTotPaHw , " & _
"running_business.RBTotPaOption,
running_business.RBTotPaSolution,running_business.RBTotPAcopy, " & _
"running_business.RBdone, running_business.flag1 " & _
"FROM running_business WHERE (running_business.IDRB = " & IDRB & ") AND
(running_business.rbstatus = 'G');"


Else

'If (DLookup("idrb", "BC", "idrb=" & IDRB)) = IDRB Then

DoCmd.RunSQL "UPDATE BC INNER JOIN running_business ON BC.IDRB > running_business.IDRB " & _
"SET BC.IDRB = [running_business].[IDRB], " & _
"BC.IDcompany = [running_business].[IDcompany], " & _
"BC.IDcontact = [running_business].[IDcontact], " & _
"BC.RBstart = [running_business].[RBstart], " & _
"BC.RBref = [running_business].[RBref], " & _
"BC.RBstatus = [running_business].[RBstatus], " & _
"BC.RBforecastdate = [running_business].[RBforecastdate], " & _
"BC.RBcatprod = [running_business].[RBcatprod], " & _
"BC.RbQuArt = [running_business].[RbQuArt], " & _
"BC.RBTotalHw = [running_business].[RBTotalHw], " & _
"BC.RBTotalOption = [running_business].[RBTotalOption], " & _
"BC.RBTotalSolution = [running_business].[RBTotalSolution], " & _
"BC.RBclickvolume = [running_business].[RBclickvolume], " & _
"BC.RBestimforecast = [running_business].[RBestimforecast], " & _
"BC.RBforecastCA = [running_business].[RBforecastCA], " & _
"BC.RBdonestatus = [running_business].[RBdonestatus], " & _
"BC.RBcomment = [running_business].[RBcomment], " & _
"BC.RBdetail = [running_business].[RBdetail], " & _
"BC.RBTotPaHw = [running_business].[RBTotPaHw], " & _
"BC.RBTotPaOption = [running_business].[RBTotPaOption], " & _
"BC.RBTotPaSolution = [running_business].[RBTotPaSolution] " & _
"FROM running_business WHERE (running_business.IDRB = " & IDRB & ")
AND (running_business.rbstatus = 'G');"


End If
"Pierre CFI [mvp]" wrote in message
news:%
moi aussi, tu veux redonner ton code update qui coince, parce que qu'avec
les 2 zozos je sais plus ou on en est, comme ils

pataugent, j'arrive (avec les assistantes)

--
Pierre CFI
MVP Microsoft Access
Mail : http://cerbermail.com/?z0SN8cN53B

Site pour bien commencer
http://users.skynet.be/mpfa/
Site perso
http://access.cfi.free.fr
"fth" a écrit dans le message de
news:408e7a8a$0$21491$

" une douzaine de vahinées qui scrutent les news sur des écran plasma
70"....
Y en a qui savent réunir les bonne conditions de travail.....chtejure
:-))


...

bon, ça y est, vous m'avez déconcentré avec vos histoires ...

NB: je parlais des écrans hein...

"Raymond [mvp]" wrote in message
news:
C'est pour ça que tu insistes pour venir travailler avec moi, mais
tant



que
ta motivation ne sera pas uniquement tournée mpfa, je refuserais.

--
@+
Raymond Access MVP
http://access.seneque.free.fr/
http://access2003.free.fr/
http://users.skynet.be/mpfa/ pour débuter sur le forum


"Pierre CFI [mvp]" a écrit dans le message
de



news:
oui, mais raymond il a pas beaucoup de mérite. Une douzaine
d'assistantes


(jeunes informaticiennes venues des iles) qui scructent
les news sur des écrans plasma 70 '' :o))

--
Pierre CFI


















Avatar
Raymond [mvp]
Evidemment, 1/2 h après l'affichage de la réponse des autres.

--
@+
Raymond Access MVP
http://access.seneque.free.fr/
http://access2003.free.fr/
http://users.skynet.be/mpfa/ pour débuter sur le forum


"Pierre CFI [mvp]" a écrit dans le message de
news:%
a la fin de update le from est de trop
"FROM running_business WHERE (running_business.IDRB = " & IDRB &
")

AND (running_business.rbstatus = 'G');"



--
Pierre CFI


Avatar
fth
Bonjour Daniel,
Oui, javais pensé à cette methode au début, mais pour différentes raisons,
le passage d'une partie des champs d'une table à l'autre convenait mieux
(multi user - confidentialité etc...)

merci et bonne fin de journée

Frédéric

"Daniel Carollo" wrote in
message news:u5$$
Bonjour Frederic!

Il y a moyen de faire beaucoup plus simple: une table seulement, avec une
colonne supplementaire qui donne le status: En_Cours, Gagnee et
Facturee...


J'espere que ca vous met la puce a l'oreille.

--
Daniel :-)

Computing Technologies International - www.computing-tech.com - We
provide solutions...

"fth" wrote in message
news:408e5c6f$0$21470$
Re bonjour,

pour plus de clarté, voici l'explication de ce qui devrait se passer:
3 tables:
running_business-----les affaires en cours
BC------------------une affaire gagnée (running_business.rbstatus="G")
devient une commande
facture--------------la facturation (BC.facture = yes) de la commande
passe

dans la table "facture"

en fonction du déroulement des activités, les infos passent d'une table
à


l'autre
Seules les affaires en cours gagnées passent en commande
mm opération pour passer de BC à Facture

encore merci

Frederic






Avatar
Daniel Carollo
Bonsoir Frederic!

Coffailler la structure ne va certainement pas rendre les choses mieux au
niveau de la confidentialite ou des acces par multi-utilisateurs.
Par exemple, pour la confidentialite, il suffit de ne pas donner acces aux
tables aux utilisateurs, ils doivent obligatoirement passer par des requetes
(ou vues) qui ont, elles, les permissions idoines. C'est beaucoup plus
simple au niveau de la maintenance. 4 heures pour faire fonctionner le
changement d'une valeur, le reste de l'application risque de vous faire
accumuler les heures supplementaires...
Le jour ou vous faites un changement dans la structure de la base, il va
vous falloir changer au moins trois tables, et facilement une demi-douzaine
de requetes. Avec des enonces tordus comme vous nous avez montre dans ce
fil, je parie que dans deux ans vous ne vous y retrouvez pas.
Dans trois ans, votre successeur met tout a la poubelle et recommence a zero
parcequ'il n'arrive pas a comprendre votre code.

Mais comme d'habitude, "pourquoi faire simple alors qu'il est si simple de
faire complique"?

Moi je dis ca, c'est juste parce que j'aime bien raler... ;-)


--
Daniel :-)

Computing Technologies International - www.computing-tech.com - We
provide solutions...

"fth" wrote in message
news:408e84db$0$21782$
Bonjour Daniel,
Oui, javais pensé à cette methode au début, mais pour différentes raisons,
le passage d'une partie des champs d'une table à l'autre convenait mieux
(multi user - confidentialité etc...)

merci et bonne fin de journée

Frédéric


1 2 3