Update table problem

  • Thread starter Thread starter Les
  • Start date Start date
L

Les

I am trying to create a running sum with the follwing code. The results are
displayed in a Datasheet sub form.

strProductCode is "Text". CurTotal & curRunning_Sum are Currency types.

I am getting a message "To few paramenters Expected 1"

Can't see what wrong can anyone help please.

Thanks

Les

'Create running sum

Dim Runtot As Integer
Dim strsql As String
Dim PCode As String

Runtot = 0

Set Sumlist = CurrentDb.OpenRecordset("tblOrder_Details") 'table Name
PCode = Sumlist!strProduct_Code

If Sumlist.BOF Then 'BOF=no results from tbl
MsgBox "There Are Calculations To Be Made."
Else

Sumlist.MoveFirst

Do
Runtot = Runtot + Sumlist![curTotal]
strsql = "Update tblOrder_Details Set curRunning_Sum = " & Runtot & "
WHERE Product = '" & PCode & "'"
CurrentDb.Execute strsql, dbFailOnError

Sumlist.MoveNext

Loop Until Sumlist.EOF

End If
 
Back
Top