Bonjour,
J'ai un problème avec ce code il ne fonctionnent pas. je travail sur access 2007 pour un projet qui sera sur access 2003 et j'utilise un livre sur le vba access 2002.
Voilà le code:
Private Sub cmdEnreg_Click()
Dim db As Connection
DoCmd.Hourglass True
Set db = CurrentProject.Connection
db.Execute " INSERT INTO TblProduit VALUES LibProduit = " & txtNomPdt.Text & " , N°Catégorie = (SELECT N°Catégorie FROM TblCatégorieProduit WHERE LibCatégorie = " & lstCategorie.Text & " ) , Conditionnement = " & txtConditionnement.Text & " , N°Fournisseur = ( SELECT N°Fournisseur FROM TblFournisseur WHERE RaisonSociale = " & LstFournisseur.Text & " ) , RéfFournisseur = " & txtRefFourn.Text & " , Commentaire = " & txtCommentaire.Text & " ; "
db.Execute " INSERT INTO TblTarifs VALUES N°Produit = ( SELECT N°Produit FROM TblProduit WHERE LibProduit = " & txtNomPdt.Text & " ) , Année = " & txtAnnée.Text & " , DateActualisation = " & txtDateActu.Text & " , DateDébut = " & txtDateDébut & " , DateFin = " & txtDateFin & " Commentaire = " & txtCommentaire.Text
If lstCategorie.Text = "Parquet" Then
If lstTypeParquet.Text = "Massif" Then
db.Execute " INSERT INTO TblParquet VALUES N°Produit = ( SELECT N°Produit FROM TblProduit WHERE LibProduit = " & txtNomPdt.Text & " ) , Essence = ( SELECT idNatureBois FROM tblNatureBois WHERE NatureBois = " & lstNatureBois.Text & " ) , Epaisseur = " & txtEpaisseurBois.Text & " , Longueur = " & txtLongueur.Text & " , Largeur = " & txtLargeur.Text & " , Bordure = " & txtBordure.Text & " , Commentaire = " & txtCommentaire.Text & " ; "
End If
If lstTypeParquet.Text = "Contre Colé" Then
db.Execute " INSERT INTO TblParquet VALUES N°Produit = ( SELECT N°Produit FROM TblProduit WHERE LibProduit = " & txtNomPdt.Text & " ) , Essence = ( SELECT idNatureBois FROM tblNatureBois WHERE NatureBois = " & lstNatureBois.Text & " ) , Epaisseur = " & txtEpaisseurBois.Text & " , Longueur = " & txtLongueur.Text & " , Largeur = " & txtLargeur.Text & " , NombreDeFrise = " & txtNbFrise.Text & " , Commentaire = " & txtCommentaire.Text & " ; "
End If
End If
If lstCategorie.Text = "Abrasif" Then
If lstTypeAbrasif.Text = "Rouleau" Then
db.Execute " INSERT INTO TblAbrasif VALUES N°Produit = ( SELECT N°Produit FROM TblProduit WHERE LibProduit = " & txtNomPdt.Text & " ) , EpaisseurGrain = " & txtEpaisseurGrain.Text & " , Longueur = " & txtLongueur.Text & " , Largeur = " & txtLargeur.Text & " , Commentaire = " & txtCommentaire & " ; "
End If
If lstTypeAbrasif.Text = "Disque" Then
db.Execute " INSERT INTO TblAbrasif VALUES N°Produit = ( SELECT N°Produit FROM TblProduit WHERE LibProduit = " & txtNomPdt.Text & " ) , EpaisseurGrain = " & txtEpaisseurGrain.Text & " , Diamètre = " & txtDiamètre.Text & " , Commentaire = " & txtCommentaire & " ; "
End If
If lstTypeAbrasif.Text = "Bande sans fin" Then
db.Execute " INSERT INTO TblAbrsif VALUES N°Produit = ( SELECT N°Produit FROM TblProduit WHERE LibProduit = " & txtNomPdt.Text & " ) , EpaisseurGrain = " & txtEpaisseurGrain.Text & " , Longueur = " & txtLongueur.Text & " , Largeur = " & txtLargeur.Text & " , Commentaire = " & txtCommentaire & " ; "
End If
If lstTypeAbrasif.Text = "Grille" Then
db.Execute " INSERT INTO TblAbrasif VALUES N°Produit = ( SELECT N°Produit FROM TblProduit WHERE LibProduit = " & txtNomPdt.Text & " ) , Diamètre = " & txtDiamètre.Text & " , Commentaire = " & txtCommentaire & " ; "
End If
If lstTypeAbrasif.Text = "Pad" Then
db.Execute " INSERT INTO TblAbrasif VALUES N°Produit = ( SELECT N°Produit FROM TblProduit WHERE LibProduit = " & txtNomPdt.Text & " ) , Diamètre = " & txtDiamètre.Text & " , Commentaire = " & txtCommentaire & " ; "
End If
End If
If lstCategorie.Text = "Liquide" Then
db.Execute " INSERT INTO TblLiquide VALUES N°Produit = ( SELECT N°Produit FROM TblProduit WHERE LibProduit = " & txtNomPdt.Text & " ) , TypeLiquide = ( SELECT N°Type FROM TblTypeLiquide WHERE LibTypeLiquide = " & lstTypeLiquid.Text & " , Effet = " & txtEffet.Text & " , Commentaire = " & txtCommentaire & " ; "
End If
If lstCategorie.Text = "Outillage" Then
db.Execute " INSERT INTO TblOutillage VALUES N°Produit = ( SELECT N°Produit FROM TblProduit WHERE LibProduit = " & txtNomPdt.Text & " ) , N°Employé = ( SELECT idEmploye FROM tblEmployes WHERE NomEmploye = " & lstEmploye.Text & " , DateAquisition = " & txtDate.Text & " , Commentaire = " & txtCommentaire & " ; "
End If
End Sub
Merci d'avance
Configuration: Windows XP
Firefox 2.0.0.14