cs_khier
Messages postés19Date d'inscriptiondimanche 23 mars 2003StatutMembreDernière intervention31 mars 2009
-
21 sept. 2008 à 06:58
nhervagault
Messages postés6063Date d'inscriptiondimanche 13 avril 2003StatutMembreDernière intervention15 juillet 2011
-
21 sept. 2008 à 18:29
salut
je suis debutant en visuel basic , jai creer une programme avec base de donne access
mais le probleme a chaque fois valider les enregistrement je trouve cette message:
( vous avez essayer de valider ou d'annuler une transaction sans debuter de de transaction au préalable)
voila la fonction enregistrer:
Private Sub cmdsave_Click()
On Error GoTo err
Dim bm
If validate() = False Then Exit Sub
With Data1.rsUL
If (.State = adStateClosed) Then: .Open
If (modstate = False) Then: .AddNew
.Fields("Num_L") = txtt_code.Text
.Fields("Adresse") = txtt_name.Text
.Fields("Ville") = Txt_ville.Text
If txtisbn.Text = "" Then
.Fields("Cartes") = Null
Else
.Fields("Cartes") = txtisbn.Text
End If
.Fields("Tel") = txtt_tel.Text
.Fields("Fax") = txtFax.Text
.Fields("Nbr_synd") = txt_nbrs.Text
' concatenate the fractional part to the price amount
' .Fields("Finances") = txtprice.Text & "." & txtdigits.Text
.Update
' if purchasesform is open then reflect the changes in the form
' regarding the title name, price etc.
If purchasesformisopen Then
With Data1.rspurchases
If .RecordCount > 0 Then bm = .Bookmark
Set frmpurchases.DataGrid1.DataSource = Nothing
.Close
.Open
Set frmpurchases.DataGrid1.DataSource = Data1
If .RecordCount > 0 Then .Bookmark = bm
End With
End If
If salesformisopen Then
With Data1.rssales
If .RecordCount > 0 Then bm = .Bookmark
Set frmsales.DataGrid1.DataSource = Nothing
.Close
.Open
Set frmsales.DataGrid1.DataSource = Data1
If .RecordCount > 0 Then .Bookmark = bm
End With
End If
If modstate = False Then
If titlesformisopen Then
.Close
.Open
Set frmtitles.DataGrid1.DataSource = Data1
If (.Filter <> adFilterNone) Then
.Filter = adFilterNone
frmtitles.cmdremfilter.Enabled = False
End If
.Find .Fields(0).Name & "='" & txtt_code.Text & "'"
End If
If MsgBox("Do you want to add a new record?", vbQuestion + vbYesNo + vbDefaultButton1) = vbYes Then
cmdreset_Click
txtt_code.Text = makecode()
Else
If Not titlesformisopen Then
.Close
Else
If frmtitles.cmdDelete.Enabled = False Then frmtitles.enablecontrols True
End If
Unload Me
End If
Else
' close and open of the recordset is necessary for refreshing the
' recordset as it is based on a query which will be invoked against the
' changed records only if it is reopened
Set frmtitles.DataGrid1.DataSource = Nothing
.Close
.Open
.Find .Fields(0).Name & "='" & txtt_code.Text & "'"
Set frmtitles.DataGrid1.DataSource = Data1
Unload Me
End If
End With
Data1.conn.CommitTrans
Exit Sub
err:
Data1.conn.RollbackTrans ' point arret l'erreur
If titlesformisopen Then
Set frmtitles.DataGrid1.DataSource = Nothing
Data1.rsUL.CancelUpdate
Set frmtitles.DataGrid1.DataSource = Data1
Else
Data1.rsUL.CancelUpdate
End If
MsgBox err.Description, vbCritical, "Error"
End Sub
aider moi svp
lillith212
Messages postés1229Date d'inscriptionvendredi 16 novembre 2007StatutMembreDernière intervention16 juin 2009 21 sept. 2008 à 17:31
Bonjour,
Je recommence : Tu es bien en vb6???
Dim bm --> Qu'est ce que c'est????
validate()--> fonction qui renvoi un boolèen mais qui fait quoi?
Data1.conn.RollbackTrans--> Le rollbacktrans j'ai jamais vu
Quand tu fais un pas à pas pourquoi tu passe tout de suite sur ton goto??? à quel moment?
SLB.
lillith212
Messages postés1229Date d'inscriptionvendredi 16 novembre 2007StatutMembreDernière intervention16 juin 2009 21 sept. 2008 à 17:40
ReBonjour,
Question : Pourquoi avoir reposter un sujet alors que tu avais ouvert le meme???
Question : As-tu fait attention aux remarques qui t'ont été faite???
En effet tu as posté ton code mais il me semble que dedenet2 t'a posé des questions... Questions auquelles bien sur tu n'as pas répondu...
Bon coding