Full Version: problems with DSUM
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
KHarris
I have a form with a subform that displays all records associated with an invoice. The subform displays in continuous form. One of the fields asks user to enter a % that line represents as an allocation factor. In other words if there is one line the % is 100% if more than one the total of all must be 100%. That is where the DSUM comes in. I want to be able to test the entry before saving to be sure the entry totals 100%. I created an unbound text box and loaded this in the control source =DSum("[svp%]","[frmsvpdata]"). The text box displays #error also when entered this in the control field i got a popup message that says that "a property of the automation object requires or returns a data type not supported by VB"??

My thought was to do the dsum then run an if statement that checks to see if the sum is 100%, if not then i would pop up a message box.

Help?
Jack Cowley
DSum("[FieldToSum", "TableName")

It appears you are using the forms name instead of the table to look for the data... Check DSum() in Access help for more details on this Function...

hth,
Jack
KHarris
Your right i was referencing the form. When i change it to the table though, it now sums all % for the entire table. I need to be able to set criteria to limit it to just the invoice that is diplayed in the subform.
Jack Cowley
DSum("[FieldToSum]", "TableName", "Criteria")

This article will show you the correct way to set up your criteria. The examples are for the DLookup() function but the syntax is exactly the same...

hth,
Jack
KHarris
Thanks for your help. It now works!
Jack Cowley
You are most welcome and I am glad to hear you got your code to work. Continued success with the project!

Jack
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.