Sum records to a textbox

G

Guest

Hey

I have a table A and a table B with different records and one field ID
linking B to A.
Then I have a Form with some controls and the forms record source is linked
to table A. One of the controls in the form is a textbox.
The user is allowed to insert records into table B, and therefore I want to
view the results in the textbox.
In this example, I want to sum the deposits the user makes.

In SQL language:

SELECT deposit FROM B WHERE B.ID = A.ID
....and then sum the result.

But I want this to happen in a textbox, and as far as I know, I can't insert
SQL Selects into the control source of a textbox. Is it possible to use the
Expression Builder to calculate this sum of the records in B, where B.ID =
A.ID?

Hope this example is not too confusing ;-)
 
R

Rob Oldfield

Use a dsum. Set the source of the text box to something like...

=dsum("[Deposit]","b","id="&[ctlNameOfTheIDField])

or

=dsum("[Deposit]","b","id='"&[ctlNameOfTheIDField]&"'")

if the id field is text.
 
G

Guest

Hey Rob.

I think that did it. Thank You very much for your quick and simple reply.

/Chau

Rob Oldfield said:
Use a dsum. Set the source of the text box to something like...

=dsum("[Deposit]","b","id="&[ctlNameOfTheIDField])

or

=dsum("[Deposit]","b","id='"&[ctlNameOfTheIDField]&"'")

if the id field is text.


Chau said:
Hey

I have a table A and a table B with different records and one field ID
linking B to A.
Then I have a Form with some controls and the forms record source is linked
to table A. One of the controls in the form is a textbox.
The user is allowed to insert records into table B, and therefore I want to
view the results in the textbox.
In this example, I want to sum the deposits the user makes.

In SQL language:

SELECT deposit FROM B WHERE B.ID = A.ID
...and then sum the result.

But I want this to happen in a textbox, and as far as I know, I can't insert
SQL Selects into the control source of a textbox. Is it possible to use the
Expression Builder to calculate this sum of the records in B, where B.ID =
A.ID?

Hope this example is not too confusing ;-)
 

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