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