DSum ?

A

an

Hi!

I have a main form with:

1Numeric textbox tichet mark
2Numeric textbox tichet mark
3Numeric textbox tichet mark
....
nNumeric textbox tichet mark

I would like in another textbox where to calc the SUM Numeric texboxes
values, only where respective ticket mark=Yes

Thanks in advance.
an
 
A

Al Campagna

an,
I'm assuming that what you call a "Numeric textbox tichet mark" is
really a Checkbox control... and... if the table fields "bound" to each
Checkbox is a Boolean True/False (as it probably should be), then
they each have a value of either 0 (false) or -1 (true).

Summing them would be simply....
=Abs(Chk1+Chk2+Chk3... etc... ChkN)
or
=(Chk1+Chk2+Chk3... etc... ChkN) * -1

If those checkboxes aren't bound to boolean fields, please describe your
setup in more detail, and give example values.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
A

an

A C
Thank you for replay.

My Main Form is continuous form...
In Detail I have a textbox named "Value" and respective ticket mark named
"Confirm" to confirmation.
In Form Footer I have a textbox to SUM values, only ticket mark = Yes.

Thanks.
an
 
J

John W. Vinson

A C
Thank you for replay.

My Main Form is continuous form...
In Detail I have a textbox named "Value" and respective ticket mark named
"Confirm" to confirmation.
In Form Footer I have a textbox to SUM values, only ticket mark = Yes.

It's simpler to do this in the Query upon which the form is based, rather than
in the form itself. Open the form in design view; find its Recordsource
property (first on the Data tab). Click the ... icon by it and open the query
design window (Access may ask if you want to do so).

In a vacant Field cell in the query type:

ConfirmedValue: IIF([Confirm], [Value], 0)

Close the query window and accept Access' offer to save it.

Then put a textbox on the footer of your form with a control source

=Sum([ConfirmedValue])

to add the checked values.
 
A

Al Campagna

an,
*If*... as we discussed, the Confirm checkbox is bound to a boolean
True/False
field, then... in the forms Footer...
=Sum(Confirm) * -1
or
=Abs(Sum(Confirm))
will yield the number of True checkboxes.

Any Confirms that are True (checked) are equal to -1
Any Confirms that are False (unchecked) are equal to 0

So... just add them up, and multiply by -1, to yield a positive number
or
Use the ABS to yield a positive number.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
A

an

Sorry, but when query run, or open form, return:

'Enter Parameter Value'
(?)

Thanks
an

John W. Vinson said:
A C
Thank you for replay.

My Main Form is continuous form...
In Detail I have a textbox named "Value" and respective ticket mark named
"Confirm" to confirmation.
In Form Footer I have a textbox to SUM values, only ticket mark = Yes.

It's simpler to do this in the Query upon which the form is based, rather than
in the form itself. Open the form in design view; find its Recordsource
property (first on the Data tab). Click the ... icon by it and open the query
design window (Access may ask if you want to do so).

In a vacant Field cell in the query type:

ConfirmedValue: IIF([Confirm], [Value], 0)

Close the query window and accept Access' offer to save it.

Then put a textbox on the footer of your form with a control source

=Sum([ConfirmedValue])

to add the checked values.
 
J

John W. Vinson

Sorry, but when query run, or open form, return:

'Enter Parameter Value'
(?)

That suggests that you have no field named Value in your table. Perhaps you
could open the query in SQL view and post it here.

Do note that your original message said 'I have a textbox named "Value"', and
I assumed (perhaps incorrectly) that it was bound to a table field named
Value.

In any case, Value is a reserved word and should not be used as the name of
any field or control - a Textbox on a form already HAS a Value property, so
it's very possible that Access will get confused!
 
A

an

Thanks for help.

an

John W. Vinson said:
That suggests that you have no field named Value in your table. Perhaps you
could open the query in SQL view and post it here.

Do note that your original message said 'I have a textbox named "Value"', and
I assumed (perhaps incorrectly) that it was bound to a table field named
Value.

In any case, Value is a reserved word and should not be used as the name of
any field or control - a Textbox on a form already HAS a Value property, so
it's very possible that Access will get confused!
 
A

Al Campagna

John,
Thanks for picking up on "Value" being a reserved word.
I missed that...
Al Campagna
 
A

an

Hi!

In adition:
Was necessary to put Me.Recalc in AfterUpdate in checkbox .

Thanks more one time.
an
 

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

Similar Threads

Yes/No 10
change captions with conditional formatting 2
Help with dsum 4
What To Do 7
Data Type in Textbox 1
Automatically requery 1
DSum on form question 17
Textbox with fixed value 2

Top