Advertisement
Guest User

Untitled

a guest
Aug 12th, 2011
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Function Str2Sql(S As String) As String
  2.  Str2Sql = "'" & Replace$(S, "'", "''") & "'"
  3. End Function
  4.  
  5. Private Sub CmdEnregistrer_Click()
  6.  Dim rep As VbMsgBoxResult
  7.  If Len(CboCodeArt.Text) And Len(CboCatArt.Text) And Len(TxtLibArt.Text) And Len(TxtPu.Text) And Len(TxtUnitArt.Text) Then
  8.   rep = MsgBox("Etes-vous sûr de vouloir enregistrer cet article?", vbYesNo, "Articles")
  9.   If rep = vbYes Then
  10.    Call Connexion1
  11.    If rs.EOF = False Then
  12.     MsgBox "Cet article existe déjà. En enregistrer un autre svp!", vbCritical, "Articles"
  13.     Call Annul
  14.     Exit Sub
  15.    Else
  16.     'enregistrement article
  17.    If Len(CboCodeArt.Text) > 5 Then
  18.      MsgBox "Le code ne doit pas dépasser 5 caractères!", vbInformation, "Articles"
  19.      Call Annul
  20.      Exit Sub
  21.     End If
  22.     taConnexion.Execute "INSERT INTO taTable(codeart, refcatart, libart, puart, unitart) VALUES (" & Str2Sql(CboCodeArt.Text) & "," & _
  23.                                         Str2Sql(CboCatArt.Text) & "," & Str2Sql(UCase(TxtLibArt.Text)) & "," & Str2Sql(TxtPu.Text) & "," & Str2Sql(UCase(TxtUnitArt.Text)) & ")"
  24.     MsgBox "L'enregistrement s'est déroulé avec succès", vbInformation, "Articles"
  25.     'màj liste combo codeart
  26.    CboCodeArt.Clear
  27.     Call Connexion_Art
  28.     Do Until rsart.EOF
  29.      CboCodeArt.AddItem rsart!codeart
  30.      rsart.MoveNext
  31.     Loop
  32.     Call Annul
  33.     Exit Sub
  34.    End If
  35.   Else
  36.    Call Annul
  37.    Exit Sub
  38.   End If
  39.  Else
  40.   MsgBox "Donnez tous les renseignements voulus svp!!!", vbCritical, "Articles"
  41.   Call Test
  42.  End If
  43. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement