79164241

Date: 2024-11-06 20:52:38
Score: 2.5
Natty:
Report link

i got same error

3061' Too few parameters. Expected 2. anyone help me please

here is vb code

Private Sub Form_AfterUpdate()
On Error GoTo ErrorHandler

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim calculatedSalesPercents As Double
Dim salesPercentsID As Variant

' Store the value of the SalesPercents control and calculate the result
calculatedSalesPercents = IIf([RePrice] = 0 Or [BDDUTY] = 0, 0, Round(1 - ([BDDUTY] / [RePrice]), 2))
salesPercentsID = Forms![Item Menu Suplier(03)]![SalesPercents]  ' Value from the SalesPercents textbox

' Set up the database and recordset
Set db = CurrentDb()
' Add the value from the SalesPercents textbox directly to the SQL statement
Set rs = db.OpenRecordset("SELECT * FROM ItemName WHERE ID = " & salesPercentsID, dbOpenDynaset)

' If a record is found, update it
If Not rs.EOF Then
    rs.Edit
    rs("SalesPercents") = calculatedSalesPercents
    rs.Update
End If

rs.Close
Set rs = Nothing
Set db = Nothing
Exit Sub

ErrorHandler: MsgBox "Error " & Err.Number & ": " & Err.Description End Sub

Reasons:
  • Blacklisted phrase (1): help me
  • RegEx Blacklisted phrase (2): help me please
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Ahmad