I’m trying to use this little tid bit of vba code to fill in some textboxes on a report I’m putting together without any kind of luck finding anything on google.
Private Sub Report_load()
Dim db As DAO.Database
Dim rst As DAO.Recordset
10 Set db = CurrentDb
20 Set rst = db.OpenRecordset("FoodLogDetails")
30 If rst.RecordCount = 0 Then GoTo Cleanup
40 rst.MoveFirst
50 Do Until rst.EOF
60 Select Case rst![WhichMeal]
61 Case "Breafast" 'if matched add to textbox others
70 txtBrkCalTot = txtBrkCalTot + TotalCalories 'total calories
80 Case "AM Snack"
90 Case "Lunch"
100 Case "PM Snack"
110 Case "Dinner"
120 Case "Evening Snack"
130 End Select
140 rst.MoveNext
150 Loop
160 Debug.Print WhichMeal
Cleanup:
db.Close
rst.Close
Set rst = Nothing
End Sub
I've tried different thing and kept getting different errors. The one I get with the current snip is at line 20, Run time error # 3061 - Too few parameters. Expected 1. I’m using a query for my recordset and the same one the report is bound to. I’ve used this code in other parts of my app and it’s worked fine. But its been used with forms and subforms not reports. I’m thinking that may have something to do with it but not sure. If anybody could help I sure would appreciate it. I’m using Access 2013
Steven