I wrote a function that goes to the table tblPayment and pull out all the records where bill _id is equal to the argument I send to the function. Then, in a loop I check each recorde whether the field "paid" = 1. If it is equal to 1, I accumulate the amount.
Unfortunate, I get a compaile error in - rst.FindFirst
The error message is: argument not optional.
The error message is: argument not optional.
I have no idea what's wrong
.
Does anyone got any suggestions?

Does anyone got any suggestions?
This is the Function:
PHP:
[left][font=Tahoma]Public Function end_payment (bill _id)[/font]
[font=Tahoma] [/font][/left][font=Tahoma][/font]
[font=Tahoma]Dim rst As dao.Recordset[/font]
[font=Tahoma]Dim i, n, bd, c_rez, rez As Integer, tb, w, q As String[/font]
[font=Tahoma]rez = 0[/font]
[font=Tahoma]tb = " tblPayment "[/font]
[font=Tahoma] [/font]
[font=Tahoma]bd = bill _id[/font]
[font=Tahoma]w = " where bill _id =" + bd[/font]
[font=Tahoma]q = "select * from " + tb + w[/font]
[font=Tahoma]Set rst = CurrentDb.OpenRecordset(q([/font]
[font=Tahoma] n = rst.RecordCount[/font]
[font=Tahoma] If n Then[/font]
[font=Tahoma] For i = 0 To n - 1[/font]
[font=Tahoma] If i = 0 Then[/font]
[font=Tahoma] rst.FindFirst[/font]
[font=Tahoma] Else[/font]
[font=Tahoma] rst.FindNext[/font]
[font=Tahoma] End If[/font]
[font=Tahoma]c_rez = 0[/font]
[font=Tahoma] If Not rst.BOF And Not rst.EOF Then[/font]
[font=Tahoma] If rst("paid") = 1 Then[/font]
[font=Tahoma] c_rez = rst("paid")[/font]
[font=Tahoma] End If[/font]
[font=Tahoma] rez = rez + c_rez[/font]
[font=Tahoma] Else[/font]
[font=Tahoma] Exit For[/font]
[font=Tahoma] End If[/font]
[font=Tahoma] [/font]
[font=Tahoma] Next i[/font]
[font=Tahoma] End If[/font]
[font=Tahoma] End Function
[font=Tahoma][left][/left][/font]