merci de votre aide
Laurent
B_Bouton_Click
on error goto fin
'suite du code
exit sub
fin:
if err.number = (n° de l'erreur) then
msgbox "T'exite pas sur le bouton comme ça"
resume next
end if
exit sub
end sub
pour connaitre le n° d'erreur correspondant à ce que tu veux tu fais au
préalable
dans le gestionnaire d'evenement sur click de ton bouton
tu ecris
B_Bouton_Click
on error goto fin
'suite du code
exit sub
fin:
msgbox "N° erreur = " & err.number
exit sub
end sub
comme ça tu récupères ton N° d'erreur
A ciao
"Laurent" <lol...@bigfoot.com> a écrit dans le message de news:
1bf3301c23221$7783ef80$3bef2ecf@TKMSFTNGXA10...
Je copie le code tel que je l'ai écris :
'Construction de la requète
SQLReq = "insert into SuiviBordereaux values (" & _
"""" & cf!CodCliSam & """" & "," & _
"""" & cf!MatVM & """" & "," & _
"""" & cf!Nom & """" & "," & _
"""" & cf!Prenom & """" & "," & _
"""" & cf!Popul & """" & "," & _
"#" & DateLiv & "#" & "," & _
"""" & cf!NumBL & """" & "," & _
"#" & DateDepot & "#);"
CurrentDb.Execute SQLReq
If Err.Number <> 0 Then
MsgBox "Enregistrement déjà existant"
Else
MsgBox "Insertion réussie !"
End If
'On place dans le champ NbreEnr le nombre total
d'enregistrements dans la base
cf!NbreEnr = DCount("*", "SuiviBordereaux")
Si qqn a une idée, je prend !
Laurent
>-----Message d'origine-----
>.
>
Vérifie _avant_ d'exécuter le insert si la clé existe déjà.
If DCount("*","SuiviBordereaux","CodCliSam='" & cf!CodCliSam & "'") = 0 Then
'Construction de la requête
SQLReq = Insert Into ....
CurrentDB Execute SQLReq
Else
MsgBox "Le numéro existe déjà !"
End if
--
A+
Pierre (3stone)
--------------------------------
Laurent
| laurent <lol...@bigfoot.com> a écrit dans le message :
| 1bf8d01c2322f$a697e7a0$3bef2ecf@TKMSFTNGXA10...
If DCount("*", "SuiviBordereaux", "Code_Client='" & cf!
CodCliSam & "'", "Matricule_Vm='" & cf!MatVM
& "'", "Numéro_BL='" & cf!NumBL & "'") = 0 Then
...
Cela engendre un message d'erreur : Nbre d'arguments
incorrectes ou affectation de propriété incorrecte.
Quelle est donc la synthaxe pour tester une clef multiple ?
Laurent
>-----Message d'origine-----
>.
>
Tu doit vérifier les trois champs...
"Code_Client='" & cf!CodCliSam & "' AND Matricule_Vm='" & cf!MatVM & "' AND Numéro_BL='" &
cf!NumBL & "'") = 0 Then
--
A+
Pierre (3stone)
--------------------------------
Laurent <lol...@bigfoot.com> a écrit dans le message :
1980b01c2323c$e3786520$37ef2ecf@TKMSFTNGXA13...
If DCount("*", "SuiviBordereaux", "Code_Client='" & cf!CodCliSam & "'
And Matricule_Vm='" & cf!MatVM & "'
And Numéro_BL='" & cf!NumBL & "'") = 0 Then
...
@+
--------------------------------------------
Jessy Sempere
Délégation Infra INP-BC
Tél : 32.05.28 ou 01.40.48.05.28
jessy....@sncf.fr
--------------------------------------------
Le code dans son ensemble :
If DCount("*", "SuiviBordereaux", "Code_Client='" & cf!
CodCliSam & "' AND Matricule_Vm='" & cf!MatVM & "' AND
Numéro_BL='" & cf!NumBL & "'") = 0 Then
'Construction de la requète
SQLReq = "insert into SuiviBordereaux values (" & _
"""" & cf!CodCliSam & """" & "," & _
"""" & cf!MatVM & """" & "," & _
"""" & cf!Nom & """" & "," & _
"""" & cf!Prenom & """" & "," & _
"""" & cf!Popul & """" & "," & _
"#" & DateLiv & "#" & "," & _
"""" & cf!NumBL & """" & "," & _
"#" & DateDepot & "#);"
CurrentDB Execute SQLReq
Else
MsgBox "Le numéro existe déjà !"
End If
>-----Message d'origine-----
>Salut,
>
>Tu doit vérifier les trois champs...
>
>"Code_Client='" & cf!CodCliSam & "' AND Matricule_Vm='" &
cf!MatVM & "' AND Numéro_BL='" &
>cf!NumBL & "'") = 0 Then
>
>
>
>--
>A+
>Pierre (3stone)
>--------------------------------
>
>
>
>Laurent <lol...@bigfoot.com> a écrit dans le message :
>1980b01c2323c$e3786520$37ef2ecf@TKMSFTNGXA13...
>Cela semble effectivement une bonne méthode. Mais j'ai un
>soucis car ma clef primaire est sur 3 variables. J'ai donc
>complété ce que m'a donné 3stone, et aboutit à cela :
>
>If DCount("*", "SuiviBordereaux", "Code_Client='" & cf!
>CodCliSam & "'", "Matricule_Vm='" & cf!MatVM
>& "'", "Numéro_BL='" & cf!NumBL & "'") = 0 Then
>....
>.
>
"Laurent" <lol...@bigfoot.com> a écrit dans le message de news:
1980b01c2323c$e3786520$37ef2ecf@TKMSFTNGXA13...
CurrentDB.Execute stingSQL
Laurent <Lol...@bigfoot.com> a écrit dans le message :
18d6201c2323f$b6583e00$9ee62ecf@tkmsftngxa05...
>-----Message d'origine-----
>Tu peux peut-être essayer en utilisant du vb
>par exemple avec un findfirst (on peux combiner plusieurs
champs pour faire
>une clef)
>puis tu verifies
>si nomatch = false .
>Si c'est le cas l'enregistrement existe sinon c'est gagner
>
>"Laurent" <lol...@bigfoot.com> a écrit dans le message de
news:
>1980b01c2323c$e3786520$37ef2ecf@TKMSFTNGXA13...
>Cela semble effectivement une bonne méthode. Mais j'ai un
>soucis car ma clef primaire est sur 3 variables. J'ai donc
>complété ce que m'a donné 3stone, et aboutit à cela :
>
>If DCount("*", "SuiviBordereaux", "Code_Client='" & cf!
>CodCliSam & "'", "Matricule_Vm='" & cf!MatVM
>& "'", "Numéro_BL='" & cf!NumBL & "'") = 0 Then
>....
>.
>
Laurent
et merci à tout ceux qui ont consacré du temps à mon pbe
>-----Message d'origine-----
>>>| """" & cf!MatVM & Í
{ wÀ O ìn±tü¬½tôQÿ ìR """" & "," & _
>>>| """" & cf!Nom & """" & "," & _
>>>| """" & cf!Prenom & """" & "," & _
>>>| """" & cf!Popul & """" & "," & _
>>>| "#" & DateLiv & "#" & "," & _
>>>| """" & cf!NumBL & """" & "," & _
>>>| "#" & DateDepot & "#);"
>>>|
>>>| CurrentDb.Execute SQLReq
>>>| If Err.Number <> 0 Then
>>>| MsgBox "Enregistrement déjà existant"
>>>| Else
>>>| MsgBox "Insertion réussie !"
>>>| End If
>>>|
>>>| 'On place dans le champ NbreEnr le nombre total
>>>| d'enregistrements dans la base
>>>| cf!NbreEnr = DCount("*", "SuiviBordereaux")
>>>
>>>
>>>.
>>>
>>
>>.
>>
>
>.
>