Better to use Dsum in VBA, or unbound textbox?

Sketchin

Registered User.
Local time
Today, 04:16
Joined
Dec 20, 2011
Messages
580
I have about 40 or so textboxes that are all performing a Dsum when my form opens. The code resides in the unbound textbox and looks like this:

Code:
= Nz(DSum("WorkingDays", "UniQryFiscalUsageToDateDashboardNew", "CategoryID = 1")) + Nz(DSum("UsageDays", "qryFiscalEquipmentDaysRapidProto", "CategoryID = 1"))

Is there any advantage to doing these Dsums in VBA, assigning the value to a variable and putting that in a textbox using Me.Txtbox.value = Value?
 
Why 40 DSums? Could you not simple use a TOTALS query? Or is there something more that I fail to see?
 
Could you do all these sums with a query instead, and bind the form to the query? That would probably be faster than either of the options you gave.
 
From responses so far, I think you should give us some overview of WHAT you are trying to do in plain English.

Seems you are telling us HOW you plan to do/did something for which we have no context.
 
I have attached a photo of the dashboard that is using all of the Dsums. Back when I developed this, I had taken advice from this forum on how to do it, which is why this was made the way it is.

BTW, most of the textboxes use either DCOUNT or DSUM and all are unbound.
 

Attachments

  • dashboard.jpg
    dashboard.jpg
    80.7 KB · Views: 274
I don't like adding logic to controls themselves since it makes that info hard to find, hard to document and therefore hard to maintain. For components that matter I commonly write a stats class, so cJobStats or cCustomerStats or something like that, and then when that class is initialized it delivers whatever processed values I need, and all future statistical calculations get added there. Then I can write those values to unbound controls in forms or reports as required, and there's no duplication and no ambiguity. And if you don't know how to use classes you can just use standard modules in much the same way, but it gets a little more cluttered.
 

Users who are viewing this thread

Back
Top Bottom