using array to sum fields

G

gator

is an array an effective means to sum several fields into a txtbox on a form?
Can someone provide basic code?
 
P

Piet Linden

is an array an effective means to sum several fields into a txtbox on a form?
 Can someone provide basic code?

you mean you already have your data in an array? More details please!

Arrays are pretty easy to deal with... and fairly lightweight, but a
bit more background info might be helpful... what kind of app?

you can just loop over the array and do the standard accumulator
thing... pretty much the same as looping over a recordset but much
lighter weight... and if you were gonna loop over a recordset, I'd say
use a totals query anyway...
 
M

Mike Painter

gator said:
is an array an effective means to sum several fields into a txtbox on
a form? Can someone provide basic code?
In general, no. DSum or a query will be a *LOT* faster, even if you don't
count the time to load the array.
 
G

gator

I have a form based on a table with about 30 txtboxes of numbers I want to
sum. Basically, what is the best way of going about it? I want to show the
sum in an unbound txtbox on the form
 
M

Mike Painter

gator said:
I have a form based on a table with about 30 txtboxes of numbers I
want to sum. Basically, what is the best way of going about it? I
want to show the sum in an unbound txtbox on the form

"Piet Linden" wrote:

The same type of number in a field usually indicates a bad design.
If that is the case, and we would need more information,then using related
tables and a subform will make what you want to do easy.

You can mane the textboxes TB1, TB2...TB30 and use a for loop to sum them
or you could just use This textbox = TB1 + TB2 + ... +TB30
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top