Home > Enterprise >  MS Access DSUM issue
MS Access DSUM issue

Time:02-11

I have a text box in a form that sums up an "encumbered" column with the where condition matches the ID number in that table and the ID shown in the form. I get a #Name error but all of the naming is correct.

=DSum("EncAmount",[tblEncumbrances],"[BID]='" & [frmProcurementEdit]![BudgetItemID] & "''")

tblEncumbrances is the table name, EncAmount is the column whose sum I need to add up. FrmProcurementEdit is the form that the textbox is on and BudgetItemID (Also on the form) needs to match BID(In tblEncumbrances)

Am I missing something here? Any help would be greatly appreciated!!

CodePudding user response:

The literal table name must be enclosed in quote marks. Also, there is an extra closing apostrophe delimiter.

According to your comment, linking fields are not same data type. This will definitely be an issue and really should correct data structure. However, it can be dealt with. Assuming BID is an integer number:

=DSum("EncAmount", "[tblEncumbrances]", "[BID]=" & CInt([BudgetItemID]))

or

=DSum("EncAmount", "[tblEncumbrances]", "[BID]=" & Val([BudgetItemID]))

CodePudding user response:

=DSum("[EncAmount]","tblEncumbrances","[BID]='" & [BudgetItemID] & "'")

  • Related