accesconfused
New member
- Local time
- Today, 13:15
- Joined
- Sep 28, 2015
- Messages
- 4
Hi all,
I am attempting to create a DSum argument with a year criterion(Yr =2016) (Yr is a text field in my table) and an ID criterion (Me.ID)(ID is a number field in my table). I can successfully create functions that are either criteria independently, but when I try to combine the criteria with an "AND" I receive a type mismatch error. If each criterion argument works well independently, what must I do differently to have both criteria present in one DSum function? Please see my code excerpt below:
IndvTotHours = DSum("Hours", "tbl_HoursLog", "Vol_ID = " & Me.ID) ' works correctly
YrHours = DSum("Hours", "tbl_HoursLog", "Yr='2016'") 'works correctly
IndvYrHours = DSum("Hours", "tbl_HoursLog", "Vol_ID =" & Me.ID And "Yr='2016'") ' type mismatch
I am attempting to create a DSum argument with a year criterion(Yr =2016) (Yr is a text field in my table) and an ID criterion (Me.ID)(ID is a number field in my table). I can successfully create functions that are either criteria independently, but when I try to combine the criteria with an "AND" I receive a type mismatch error. If each criterion argument works well independently, what must I do differently to have both criteria present in one DSum function? Please see my code excerpt below:
IndvTotHours = DSum("Hours", "tbl_HoursLog", "Vol_ID = " & Me.ID) ' works correctly
YrHours = DSum("Hours", "tbl_HoursLog", "Yr='2016'") 'works correctly
IndvYrHours = DSum("Hours", "tbl_HoursLog", "Vol_ID =" & Me.ID And "Yr='2016'") ' type mismatch