I need a help

Résolu/Fermé
sooprano Messages postés 33 Date d'inscription dimanche 9 décembre 2007 Statut Membre Dernière intervention 22 avril 2008 - 9 mars 2008 à 16:56
sooprano Messages postés 33 Date d'inscription dimanche 9 décembre 2007 Statut Membre Dernière intervention 22 avril 2008 - 9 mars 2008 à 19:03
Bonjour, je trvaille sur Visual basic 6 et j devellope une application et j me suis tombé sur un p'tit Probleme
c'est ke j'ai un form2 par Exemple j'ai 4 textbox (text1: N°produit , text2=libellé , text3=Prix u : text4 =Quantité en stocl) et List1 qui Port tous N°Produit saisie
le probleme c'est ke quand j supprime un Enregistrement il dois etre supprimer Aussi dans List1 Sur le Champs
j'ai fé list1.removeitem (!Num_prod) Mais ca marche pa sous ce Programme ci desus mais ca marche pa il m indique type incomptabile pouvez vous m aider svp
ainsi je veux aussi quand je enregistre les donnée il dois m afficher sur le champs le N° Produit Sur le List1
Merci

j'utilise toolbar

select case buton.index
case is = 1 'Bouton Enregistrer
va = MsgBox("Voulez Vous Vraiment" & Chr(13) & "Enregistrer Les Données", vbYesNo + vbInformation, "Confirmation")
If va = 6 Then
SQL = " insert into Produit " & _
" values ('" & Text1 & "' , '" & Text2 & "' , " & Text3 & " , " & Text4 & ")"
Base.Execute SQL
'l ajout ds list box dois etre ici
endif

case is = 3 'Bouton Supprimer

sql = " update from Produit where Num_prod = '" & text1 & "'"
base.execute sql ' base c'est variable du base donnée
' la suppression ds listbox dois etre ici
A voir également:

4 réponses

Polux31 Messages postés 6917 Date d'inscription mardi 25 septembre 2007 Statut Membre Dernière intervention 1 novembre 2016 1 204
9 mars 2008 à 16:59
bonjour,

Comment remplis-tu ta listbox ? avec une requête ? ou en dur dans le code ?

;o)

polux
0
sooprano Messages postés 33 Date d'inscription dimanche 9 décembre 2007 Statut Membre Dernière intervention 22 avril 2008
9 mars 2008 à 18:04
je remplis le listbox j le programme dans form load
Private Sub form_load()
with E_produit
if not .eof then .movefirst
while not .eof
list1.additem !Num_prod
if not .eof then .movenext
wend
end with
end sub

Private sub list1_click()
text1=list1
text1_lostfocus
end sub

Private Sub Text1_LostFocus()
If Text1 <> "" Then
With E_produit
.Index = "Produit_ndx"
.Seek "=", Text1
If Not .NoMatch Then
Text2 = !Lib_prod
Text3 = !Pu_prod
Text4 = !Qs_prod
Toolbar1.Buttons(1).Enabled = 0 'bouton Enregistrer
Toolbar1.Buttons(2).Enabled = 1 'bouton Modifier
Toolbar1.Buttons(3).Enabled = 1 'bouton Supprimer
Else
Text2.text = "": Text3.text = "": Text4.text = ""
End If
End With
End If

End Sub
0
Polux31 Messages postés 6917 Date d'inscription mardi 25 septembre 2007 Statut Membre Dernière intervention 1 novembre 2016 1 204
9 mars 2008 à 18:44
ok

fais une procédure pour remplir la listbox:

Private Sub InitListBox() 
     with E_produit 
          list1.clear
          if not .eof then .movefirst 
               while not .eof 
                    list1.additem !Num_prod 
                    if not .eof then .movenext 
               wend 
      end with 
end sub


Ensuite tu appelles la procédure dans le load de la form :

Private Sub form_load() 
     InitListBox
end sub


et tu fais appel à cette procédure (InitListBox) pour la mise à jour dans ton select case :

select case buton.index 
     case is = 1 'Bouton Enregistrer 
          va = MsgBox("Voulez Vous Vraiment" & Chr(13) & "Enregistrer Les Données", vbYesNo + VBInformation, "Confirmation") 
          If va = 6 Then 
                SQL = " insert into Produit " & _ 
                          " values ('" & Text1 & "' , '" & Text2 & "' , " & Text3 & " , " & Text4 & ")" 
                Base.Execute SQL 
                InitListBox
end if

....



;o)

polux
0
sooprano Messages postés 33 Date d'inscription dimanche 9 décembre 2007 Statut Membre Dernière intervention 22 avril 2008
9 mars 2008 à 19:03
Merci sa marche bien Pr mise a jour pr la Supression et validation a propo d mise a jour lors d la validation on peu faire

Private sub toolbar_button()
select case button.index

Case Is = 1 'Bouton Enregistrer
va = MsgBox("Voulez Vous Vraiment" & Chr(13) & "Enregistrer Les Données", vbYesNo + vbInformation, "Confirmation")
If va = 6 Then
SQL = " insert into Produit " & _
" values ('" & Text1 & "' , '" & Text2 & "' , " & Text3 & " , " & Text4 & ")"
Base.Execute SQL
list1.additem text1 'mise a jour l ors d la validation

Mais on dois programmer textbox lost focus et list1 click

private sub list1_click()
text1=list1
text1_lostfocus
end sub
voila
Merci bcp
0