Reputation: 29
I have the following code set up to sum the amount field in my qryExpenses query.
Private Sub Command18_Click()
Dim txtExpense As Currency
txtExpense = DSum("Amount", "qryExpenses")
End Sub
For some reason it is not pulling the amount into my form. Am I missing something?
Upvotes: 1
Views: 266
Reputation: 8518
As it stands now, you have declared a variable to hold the total amount, you retrieve the amount with DSum()
but you do not assign its value to the textbox control. In addition I believe you have given the variable the same name as the Textbox control.
If that's the case, change the variable name to something meaningful and then assign its value to the textbox control.
Private Sub Command18_Click()
Dim totalExpense As Currency
totalExpense = DSum("Amount", "qryExpenses")
Me.txtExpense.Value = totalExpense
End Sub
Upvotes: 2