calculated field on a form

G

Guest

Would like to add a text box that contains a calculated field containing info
from another table. Other than building a form off a query I don't know how
to do it. I thought putting =sum([name of field from other table]) would
work but it gives me #Error. The tables are related. HELP!
 
G

Guest

For this you would want the DLookup function
=DSum("[name of field from other table]", "name of table")
 
D

Douglas J. Steele

Tsk, tsk, tsk.

=DSum("[name of field from other table]", "[name of table]")

(but I assume you forgot because you never put spaces in your table names!
<g>)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Klatuu said:
For this you would want the DLookup function
=DSum("[name of field from other table]", "name of table")
--
Dave Hargis, Microsoft Access MVP


gump said:
Would like to add a text box that contains a calculated field containing
info
from another table. Other than building a form off a query I don't know
how
to do it. I thought putting =sum([name of field from other table]) would
work but it gives me #Error. The tables are related. HELP!
 
G

Guest

The first line in my naming convention reference is:
The space character does not exist. It is only a rumor.

I just copied and pasted the OP's code. Should have mentioned it.
--
Dave Hargis, Microsoft Access MVP


Douglas J. Steele said:
Tsk, tsk, tsk.

=DSum("[name of field from other table]", "[name of table]")

(but I assume you forgot because you never put spaces in your table names!
<g>)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Klatuu said:
For this you would want the DLookup function
=DSum("[name of field from other table]", "name of table")
--
Dave Hargis, Microsoft Access MVP


gump said:
Would like to add a text box that contains a calculated field containing
info
from another table. Other than building a form off a query I don't know
how
to do it. I thought putting =sum([name of field from other table]) would
work but it gives me #Error. The tables are related. HELP!
 
D

Douglas J. Steele

Thatmustmakeforsomeinterestingcodeinyourapplications.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Klatuu said:
The first line in my naming convention reference is:
The space character does not exist. It is only a rumor.

I just copied and pasted the OP's code. Should have mentioned it.
--
Dave Hargis, Microsoft Access MVP


Douglas J. Steele said:
Tsk, tsk, tsk.

=DSum("[name of field from other table]", "[name of table]")

(but I assume you forgot because you never put spaces in your table
names!
<g>)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Klatuu said:
For this you would want the DLookup function
=DSum("[name of field from other table]", "name of table")
--
Dave Hargis, Microsoft Access MVP


:

Would like to add a text box that contains a calculated field
containing
info
from another table. Other than building a form off a query I don't
know
how
to do it. I thought putting =sum([name of field from other table])
would
work but it gives me #Error. The tables are related. HELP!
 
G

Guest

Thanks for the prompt reply. This is working fine to give me the sum of ALL
records in my other table, but I wasn't clear enought on exactly what I
needed. My main table contains project specific info, and this is what the
form is created from. The other table, "Activities" tracks all time put to
these projects. I would like to show a sum of all time put to each
particular project, so that as you scroll through the Project forms, the sum
of Activity to that project changes. Using DSUM all 12000 hours show for
each project.

Klatuu said:
For this you would want the DLookup function
=DSum("[name of field from other table]", "name of table")
--
Dave Hargis, Microsoft Access MVP


gump said:
Would like to add a text box that contains a calculated field containing info
from another table. Other than building a form off a query I don't know how
to do it. I thought putting =sum([name of field from other table]) would
work but it gives me #Error. The tables are related. HELP!
 
G

Guest

Then you need to filter it by Project:
=DSum("[name of field from other table]", "name of table", "Project = " &
Project Reference Here)

I can't be more specific not knowing where you have the project code or what
data type it is.
--
Dave Hargis, Microsoft Access MVP


gump said:
Thanks for the prompt reply. This is working fine to give me the sum of ALL
records in my other table, but I wasn't clear enought on exactly what I
needed. My main table contains project specific info, and this is what the
form is created from. The other table, "Activities" tracks all time put to
these projects. I would like to show a sum of all time put to each
particular project, so that as you scroll through the Project forms, the sum
of Activity to that project changes. Using DSUM all 12000 hours show for
each project.

Klatuu said:
For this you would want the DLookup function
=DSum("[name of field from other table]", "name of table")
--
Dave Hargis, Microsoft Access MVP


gump said:
Would like to add a text box that contains a calculated field containing info
from another table. Other than building a form off a query I don't know how
to do it. I thought putting =sum([name of field from other table]) would
work but it gives me #Error. The tables are related. HELP!
 
G

Guest

onlywheniamusingnames
--
Dave Hargis, Microsoft Access MVP


Douglas J. Steele said:
Thatmustmakeforsomeinterestingcodeinyourapplications.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Klatuu said:
The first line in my naming convention reference is:
The space character does not exist. It is only a rumor.

I just copied and pasted the OP's code. Should have mentioned it.
--
Dave Hargis, Microsoft Access MVP


Douglas J. Steele said:
Tsk, tsk, tsk.

=DSum("[name of field from other table]", "[name of table]")

(but I assume you forgot because you never put spaces in your table
names!
<g>)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


For this you would want the DLookup function
=DSum("[name of field from other table]", "name of table")
--
Dave Hargis, Microsoft Access MVP


:

Would like to add a text box that contains a calculated field
containing
info
from another table. Other than building a form off a query I don't
know
how
to do it. I thought putting =sum([name of field from other table])
would
work but it gives me #Error. The tables are related. HELP!
 
G

Guest

You lost me on the "Project =" & Project Reference Here) part. Quick
overview - I have two tables, one containing project specific details and the
primary key is Project #. Linked to the Activities table with a 1-many
relationship. Employees put time to projects by selecting the project # they
are working on, name, date and actual time. There is a form showing all
project details created directly from the Project table and the project
leader would like to see the number of actual hours put to the project right
on this form, not in a separate report as it is now. The first suggestion
for DSum gives me the sum of ALL actual hours to every project, not just the
one for the record I am viewing.
Thanks for your help!

Klatuu said:
Then you need to filter it by Project:
=DSum("[name of field from other table]", "name of table", "Project = " &
Project Reference Here)

I can't be more specific not knowing where you have the project code or what
data type it is.
--
Dave Hargis, Microsoft Access MVP


gump said:
Thanks for the prompt reply. This is working fine to give me the sum of ALL
records in my other table, but I wasn't clear enought on exactly what I
needed. My main table contains project specific info, and this is what the
form is created from. The other table, "Activities" tracks all time put to
these projects. I would like to show a sum of all time put to each
particular project, so that as you scroll through the Project forms, the sum
of Activity to that project changes. Using DSUM all 12000 hours show for
each project.

Klatuu said:
For this you would want the DLookup function
=DSum("[name of field from other table]", "name of table")
--
Dave Hargis, Microsoft Access MVP


:

Would like to add a text box that contains a calculated field containing info
from another table. Other than building a form off a query I don't know how
to do it. I thought putting =sum([name of field from other table]) would
work but it gives me #Error. The tables are related. HELP!
 
G

Guest

Look in VBA Help and review the DSum function. If you want to sum just by
project, the last argument of DSum will provide that. So if Project # is the
name of the field in the table to filter by (A bad name, by the way. Names
should have only letters, numbers, and the underscore. Never use spaces, any
special character other than the underscore, or Access reserved words (Date,
Month, Name, etc)) then you need to include that reference and you have to
pass a value. In this case, it is the project number you want to filter on ,
so I would assume you have the project number somewhere on the form. Let's
call it txtProjectID for sake of example. So to sum by project:
=DSum("[Project #] = " & Me.txtProjectID

The above syntax assumes ProjectID is a numeric field. If it is text, the
syntax is:
=DSum("[Project #] = '" & Me.txtProjectID & "'"
--
Dave Hargis, Microsoft Access MVP


gump said:
You lost me on the "Project =" & Project Reference Here) part. Quick
overview - I have two tables, one containing project specific details and the
primary key is Project #. Linked to the Activities table with a 1-many
relationship. Employees put time to projects by selecting the project # they
are working on, name, date and actual time. There is a form showing all
project details created directly from the Project table and the project
leader would like to see the number of actual hours put to the project right
on this form, not in a separate report as it is now. The first suggestion
for DSum gives me the sum of ALL actual hours to every project, not just the
one for the record I am viewing.
Thanks for your help!

Klatuu said:
Then you need to filter it by Project:
=DSum("[name of field from other table]", "name of table", "Project = " &
Project Reference Here)

I can't be more specific not knowing where you have the project code or what
data type it is.
--
Dave Hargis, Microsoft Access MVP


gump said:
Thanks for the prompt reply. This is working fine to give me the sum of ALL
records in my other table, but I wasn't clear enought on exactly what I
needed. My main table contains project specific info, and this is what the
form is created from. The other table, "Activities" tracks all time put to
these projects. I would like to show a sum of all time put to each
particular project, so that as you scroll through the Project forms, the sum
of Activity to that project changes. Using DSUM all 12000 hours show for
each project.

:

For this you would want the DLookup function
=DSum("[name of field from other table]", "name of table")
--
Dave Hargis, Microsoft Access MVP


:

Would like to add a text box that contains a calculated field containing info
from another table. Other than building a form off a query I don't know how
to do it. I thought putting =sum([name of field from other table]) would
work but it gives me #Error. The tables are related. HELP!
 

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