using recordset WHERE clause

lehcarrodan

Registered User.
Local time
Today, 11:30
Joined
Feb 20, 2017
Messages
11
Having trouble getting the WHERE part to work. I know everything else's right because if I remove the WHERE section it updates all the qryPayments Paid field to true. I have a text box on a continuous form called txtStillOwing and I want when

txtStillOwing=0 to make paid=true

it's a currency field and I'm not sure I can reference the form like this? or is there an issue with the 0 do I need some quotes or something?
My CODE gives error 3061 Too few parameters. Expected 1.


Private Sub cmdPay_Click()
Me.Requery

Dim RecordSet
Set RecordSet = CurrentDb.OpenRecordset("qryPayments")

Do Until RecordSet.EOF
CurrentDb.Execute "UPDATE tblOrders SET tblOrders.Paid = true WHERE [Forms]![frmAccountReceivable]![txtStillOwing]=0"
RecordSet.MoveNext

Loop

RecordSet.Close
Set RecordSet = Nothing
CurrentDb.Close
Me.Requery

End Sub



Thanks for any help/suggestions!
 
I dont believe you can loop through a form like that so you may need a different approach. Where is the value for txtStillOwing coming from? Is it a calculated field? is the field on the form a bound field? Do you really need to have a yes/no field to show its paid off when it can just be calculated as needed?
 
Yes, the code as written will update all records in the query recordset to Paid is true, if the form is displaying 0 in the text box.

The code not only updates all records once, but as many times as the number of records in the query recordset.

Is [txtStillOwing] bound to a table field or is it a calculated field. If the latter, use the calculation formula in the where condition.
 

Users who are viewing this thread

Back
Top Bottom