I have a Split form called 'EodF' with employee names and their expenses on a particular date. I need do a Dsum for getting their total expenses in a text box based on the 'Date' in text box and their name in a combo box.
DSum in Form based on Date and Name
Collapse
X
-
Lets say that your textbox is named txtDate and your combo box is named cboEmployee. One thing that you don't tell us is if the combo box is bound to a the employee ID (numeric) or the employee name (text), so I'll provide both options. In your textbox in which you want the total expenses, enter one of the following:
(for numeric employee ID)(For text employee name)Code:=DSum("ExpenseFieldName", "TableName", "EmployeeField = " & Forms!EodF!cboEmployee & " And ExpenseDateField = #" & Forms!EodF!txtDate & "#")The difference is that text fields must have quotes around the string for which you are searching.Code:=DSum("ExpenseFieldName", "TableName", "EmployeeField = '" & Forms!EodF!cboEmployee & "' And ExpenseDateField = #" & Forms!EodF!txtDate & "#")
Just make sure to change the field names and the table name to fit what you have.
Comment