I tried to figure out what i did wrong, and i couldn't find the mistake could any one help me ??
i'm getting this message :Error 3061, Too few parameters Expected 1.
achat_num and fact_num are both required field.
i'm getting this message :Error 3061, Too few parameters Expected 1.
achat_num and fact_num are both required field.
Code:
Dim db As DAO.Database
Dim dataset1, dataset2 As DAO.Recordset
Dim sql1, sql2 As String
Dim maxfactnum, maxachatnum, Article As Long
Set db = CurrentDb
Set dataset1 = db.OpenRecordset("select nz(max(achat_num),0) as maxAchatNum from achat", dbOpenDynaset)
Set dataset2 = db.OpenRecordset("select nz(max(fact_num),0) as maxFactNum from Facture", dbOpenDynaset)
maxfactnum = CLng(dataset2![maxfactnum]) 'the maximum fact_num in the Facture table
MsgBox (maxfactnum)
maxachatnum = CLng(dataset1![maxachatnum]) ' the maximum achat_num in the achat table
newAchatNum = maxachatnum + 1 ' the new achat_num
newFactNum = maxfactnum + 1
MsgBox (newFactNum)
sql1 = "insert into Facture values(" _
& CStr(newFactNum) & ",#" & CStr(Forms![testFact]![date_fact]) & "#," _
& CStr([testFact_Subform].Form![Real]) & "," _
& CStr([testFact_Subform].Form![After]) & "," _
& CStr([testFact_Subform].Form![cash]) & "," _
& CStr([testFact_Subform].Form![diff]) & ");"
MsgBox sql1
db.Execute (sql1)
If (Not IsNull([testFact_Subform].Form![achat_num1])) Then
sql2 = "insert into achat values(" _
& CStr(newAchatNum) & "," & CStr([testFact_Subform].Form![Article1]) & "," _
& CStr([testFact_Subform].Form![size1]) & "," _
& CStr(newFactNum) & "," & CStr([testFact_Subform].Form![quantite_vendu1]) & "," _
& CStr([testFact_Subform].Form![prix_vente_unitaire1]) & "," _
& CStr([testFact_Subform].Form![Difference1]) & "," _
& CStr([testFact_Subform].Form![Type1]) & "); "
MsgBox sql2
db.Execute (sql2) 'this line is highlighted with yellow on debug
End If
Comment