Expression Builder problem

  • Thread starter Thread starter TR
  • Start date Start date
T

TR

I have a database where a new record is created daily (use forms to make
entries). One of the entries is 'distance travelled'. I'd like to add an
extra field for 'daily average distance travelled' where it updates
automatically. Can I build an expression for this field to create an average
of all the previous 'distance travelled' entries. I've tried and am not
seeming to make much sense out of it.
Thanks for any help in the offering.
bty... I'm using Access 2000.
 
I have a database where a new record is created daily (use forms to make
entries). One of the entries is 'distance travelled'. I'd like to add an
extra field for 'daily average distance travelled' where it updates
automatically. Can I build an expression for this field to create an average
of all the previous 'distance travelled' entries. I've tried and am not
seeming to make much sense out of it.
Thanks for any help in the offering.
bty... I'm using Access 2000.

Sure. Set the Control Source of a textbox to

=DAvg("[Distance Travelled]", "[name-of-your-table]", "<optional
criteria>")

Leave off the criteria if you want the average of all the distances
traveled in the entire table.

John W. Vinson[MVP]
 
John Vinson said:
I have a database where a new record is created daily (use forms to make
entries). One of the entries is 'distance travelled'. I'd like to add an
extra field for 'daily average distance travelled' where it updates
automatically. Can I build an expression for this field to create an
average
of all the previous 'distance travelled' entries. I've tried and am not
seeming to make much sense out of it.
Thanks for any help in the offering.
bty... I'm using Access 2000.

Sure. Set the Control Source of a textbox to

=DAvg("[Distance Travelled]", "[name-of-your-table]", "<optional
criteria>")

Leave off the criteria if you want the average of all the distances
traveled in the entire table.

John W. Vinson[MVP]

Thanks John,
For the control source I put " =DAvg([Text47],[Daily Diary]) " where
text47 is the name of the text box I want to reference and " Daily Diary "
is the name of the table. And I get " #Name? " in the field. Do I need to do
anything else.

TR
 
Hi TR,

I see two problems with your expression:

1.) The expression (fieldname), domain (table or query name), and optional
criteria terms must be enclosed in quotes.

2.) You need to reference the name of a field in the Daily Diary table, not
a text box on a form. While the following should return a value:

=DAvg("[Text47]","[Daily Diary]")

it will not be a correct value. Instead, you need to have something like this:

=DAvg("[NameOfField]","[Daily Diary]")

Here is a reference for using DLookup, which applies to all of the domain
aggregrate functions:

DLookup Usage Samples
http://www.mvps.org/access/general/gen0018.htm


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
Tom Wickerath said:
Hi TR,

I see two problems with your expression:

1.) The expression (fieldname), domain (table or query name), and optional
criteria terms must be enclosed in quotes.

2.) You need to reference the name of a field in the Daily Diary table,
not
a text box on a form. While the following should return a value:

=DAvg("[Text47]","[Daily Diary]")

it will not be a correct value. Instead, you need to have something like
this:

=DAvg("[NameOfField]","[Daily Diary]")

Here is a reference for using DLookup, which applies to all of the domain
aggregrate functions:

DLookup Usage Samples
http://www.mvps.org/access/general/gen0018.htm


Tom Wickerath
Microsoft Access MVP

Thanks Tom, it's been very helpful.

TR
 

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

Back
Top