Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Access
3rdpartyusrgrp
access
activexcontrol
adp.sqlserver
commandbarsui
conversion
dataaccess.pages
developers.toolkitode
devtoolkits
externaldata
forms
formscoding
gettingstarted
internet
interopoledde
macros
modulescoding
modulesdaovba
modulesdaovba.ado
multiuser
odbcclientsvr
queries
replication
reports
security
setupconfig
tablesdbdesign
  
 
date: Sun, 6 Jul 2008 10:19:01 -0700,    group: microsoft.public.access        back       


calculating averages   
Hi, 

I received a reply that my question on calculating averages had been 
answered, when I click on the link for the answer, it was blank.  Please 
respond by to my question.

Can this calculation of averages be done from a form?

Form Name is Benton
I have three fields
field one is "grade"
field two is "grade1"
field three is "grade2"

I want the average of "grade1" and "grade2" to show in the "grade" field.

Can this be done with a form only, if not is there a way I can create a 
macro, each time I try to create a macro, I only get the pre-defined actions.

Thanks for any help you can give me.
date: Sun, 6 Jul 2008 10:19:01 -0700   author:   Kit

Re: calculating averages   
Since you can do this in a form or query (or even a report) there is no need 
to store the result. In a query use an alias column:

Grade: AVG([Grade1]+[Grade2])

in a form or report, set the controlsource of the Grade textbox to:

=AVG([Grade1]+[Grade2])
-- 
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"Kit"  wrote in message 
news:72D70EBB-EBC4-4B89-859F-9081AAD3D52F@microsoft.com...
> Hi,
>
> I received a reply that my question on calculating averages had been
> answered, when I click on the link for the answer, it was blank.  Please
> respond by to my question.
>
> Can this calculation of averages be done from a form?
>
> Form Name is Benton
> I have three fields
> field one is "grade"
> field two is "grade1"
> field three is "grade2"
>
> I want the average of "grade1" and "grade2" to show in the "grade" field.
>
> Can this be done with a form only, if not is there a way I can create a
> macro, each time I try to create a macro, I only get the pre-defined 
> actions.
>
> Thanks for any help you can give me.
date: Sun, 6 Jul 2008 13:31:02 -0400   author:   Arvin Meyer [MVP]

Re: calculating averages   
Your problem actually goes back to the design of your tables. You need a 
structure like this:

TblItem
ItemID
ItemDescription

TblGrade
GradeID
Grade

TblItemGrade
ItemGradeID
ItemID
GradeID
GradeValue

You can then easily get the average you want in a query on TblItemGrade.

You should correct the design of your tables now to avoid other similar 
problems down the road.

Steve



"Kit"  wrote in message 
news:72D70EBB-EBC4-4B89-859F-9081AAD3D52F@microsoft.com...
> Hi,
>
> I received a reply that my question on calculating averages had been
> answered, when I click on the link for the answer, it was blank.  Please
> respond by to my question.
>
> Can this calculation of averages be done from a form?
>
> Form Name is Benton
> I have three fields
> field one is "grade"
> field two is "grade1"
> field three is "grade2"
>
> I want the average of "grade1" and "grade2" to show in the "grade" field.
>
> Can this be done with a form only, if not is there a way I can create a
> macro, each time I try to create a macro, I only get the pre-defined 
> actions.
>
> Thanks for any help you can give me.
date: Sun, 6 Jul 2008 14:08:14 -0400   author:   Mark

Re: calculating averages   
Hi Arvin, and thanks so very much -- I owe you one!!!

I have my controlsource set with the parameters for the avg, but it's giving 
me both field values:  i.e.  say my "grade1" is 50 and my "grade2" is 60, the 
value in "grade" comes out as 2530.  How can I merge grade1 and grade2.  I 
have them as separate fields, but if you can suggest a combined field that 
will give me one result, I sure would appreciate it.

"Arvin Meyer [MVP]" wrote:

> Since you can do this in a form or query (or even a report) there is no need 
> to store the result. In a query use an alias column:
> 
> Grade: AVG([Grade1]+[Grade2])
> 
> in a form or report, set the controlsource of the Grade textbox to:
> 
> =AVG([Grade1]+[Grade2])
> -- 
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.mvps.org/access
> http://www.accessmvp.com
> 
> 
> "Kit"  wrote in message 
> news:72D70EBB-EBC4-4B89-859F-9081AAD3D52F@microsoft.com...
> > Hi,
> >
> > I received a reply that my question on calculating averages had been
> > answered, when I click on the link for the answer, it was blank.  Please
> > respond by to my question.
> >
> > Can this calculation of averages be done from a form?
> >
> > Form Name is Benton
> > I have three fields
> > field one is "grade"
> > field two is "grade1"
> > field three is "grade2"
> >
> > I want the average of "grade1" and "grade2" to show in the "grade" field.
> >
> > Can this be done with a form only, if not is there a way I can create a
> > macro, each time I try to create a macro, I only get the pre-defined 
> > actions.
> >
> > Thanks for any help you can give me. 
> 
> 
>
date: Sun, 6 Jul 2008 11:25:00 -0700   author:   Kit

Re: calculating averages   
"Mark"  schreef in bericht news:XeidnQriy4KMl-zVnZ2dnUVZ_h_inZ2d@earthlink.com...
> Your problem actually goes back to the design of your tables. You need a 
> structure like this:
> 
> TblItem
> ItemID
> ItemDescription
> 
> TblGrade
> GradeID
> Grade
> 
> TblItemGrade
> ItemGradeID
> ItemID
> GradeID
> GradeValue
> 
> You can then easily get the average you want in a query on TblItemGrade.
> 
> You should correct the design of your tables now to avoid other similar 
> problems down the road.
> 
> Steve
 

-- 
Hey Mark/Steve!! We don't need you here !!
Hey Mark/Steve!! We don't want you here !!

This is to inform 'newbees' here about PCD' Steve:
http://home.tiscali.nl/arracom/whoissteve.html      (updated, mainly the 'abuse-reporting' page...)
Until now 5850 pageloads, 3675 first-time visitors 
(these figures are real and rapidly increasing)

Why is this ???
Because Steve is the ONLY person here who continues to advertise in the groups.

It is not relevant whether he advertised in *this* particular post or not...
==> We want him to know that these groups are *not* his private hunting grounds!

For those who don't like too see all these messages:
==> Simply killfile 'StopThisAdvertising'. 
Newbees will still see this warning-message.

ArnoR
date: Mon, 7 Jul 2008 00:42:37 +0200   author:   StopThisAdvertising StopThisAdvertising@DataShit

Re: calculating averages   
I'm wondering whether what you actually want is the average of the two values 
in the controls on the form rather than the average of a set of values in the 
form's underlying recordset.  If so don't use the Avg function but a 
ControlSource of:

=(Val([Grade1])+Val([Grade2]))/2

However, if Grade1 and Grade2 are in fact columns in a table then Mark (aka 
Steve) is, despite Arno's strictures, actually right about the flawed design 
of the table.  It should be decomposed as he suggests, but as Grade will be a 
set of unique values in the tblGrade table you can just have the one column 
Grade as the primary key of that table, and a corresponding Grade foreign key 
in the tblItemGrade table, with referential integrity and cascade updates 
enforced in the relationship between the two tables.  The ControlSource for 
an unbound text box to show the average grade per 'item' in a form based on 
the tblItem table would then be:

=DAvg("GradeValue", "tblItemGrade", "ItemID = " & [ItemID)

though a more likely scenario would be to have a form based on tblItem with 
a continuous subform based on tblItemGrade embedded within it, linked to the 
parent form on ItemID, in which case you'd have a text box in the subform's 
footer with a ControlSource property of:

=Avg([GradeValue])

We don't really have enough information from you about what your database 
represents in terms of the real world to say which way you should be going.

Ken Sheridan
Stafford, England 

"Kit" wrote:

> Hi Arvin, and thanks so very much -- I owe you one!!!
> 
> I have my controlsource set with the parameters for the avg, but it's giving 
> me both field values:  i.e.  say my "grade1" is 50 and my "grade2" is 60, the 
> value in "grade" comes out as 2530.  How can I merge grade1 and grade2.  I 
> have them as separate fields, but if you can suggest a combined field that 
> will give me one result, I sure would appreciate it.
> 
> "Arvin Meyer [MVP]" wrote:
> 
> > Since you can do this in a form or query (or even a report) there is no need 
> > to store the result. In a query use an alias column:
> > 
> > Grade: AVG([Grade1]+[Grade2])
> > 
> > in a form or report, set the controlsource of the Grade textbox to:
> > 
> > =AVG([Grade1]+[Grade2])
> > -- 
> > Arvin Meyer, MCP, MVP
> > http://www.datastrat.com
> > http://www.mvps.org/access
> > http://www.accessmvp.com
> > 
> > 
> > "Kit"  wrote in message 
> > news:72D70EBB-EBC4-4B89-859F-9081AAD3D52F@microsoft.com...
> > > Hi,
> > >
> > > I received a reply that my question on calculating averages had been
> > > answered, when I click on the link for the answer, it was blank.  Please
> > > respond by to my question.
> > >
> > > Can this calculation of averages be done from a form?
> > >
> > > Form Name is Benton
> > > I have three fields
> > > field one is "grade"
> > > field two is "grade1"
> > > field three is "grade2"
> > >
> > > I want the average of "grade1" and "grade2" to show in the "grade" field.
> > >
> > > Can this be done with a form only, if not is there a way I can create a
> > > macro, each time I try to create a macro, I only get the pre-defined 
> > > actions.
> > >
> > > Thanks for any help you can give me. 
> > 
> > 
> >
date: Sun, 6 Jul 2008 17:09:00 -0700   author:   Ken Sheridan

Re: calculating averages   
It look as though you are getting the values from the underlying recordset. 
In the text box try naming the text box slightly different than the field:

=AVG([txtGrade1]+[txtGrade2])

If you are still having the problem, my gues is that you are using a subform 
and it is averaging those values.
-- 
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"Kit"  wrote in message 
news:A420C025-98D0-4344-904C-703AE6B4998F@microsoft.com...
> Hi Arvin, and thanks so very much -- I owe you one!!!
>
> I have my controlsource set with the parameters for the avg, but it's 
> giving
> me both field values:  i.e.  say my "grade1" is 50 and my "grade2" is 60, 
> the
> value in "grade" comes out as 2530.  How can I merge grade1 and grade2.  I
> have them as separate fields, but if you can suggest a combined field that
> will give me one result, I sure would appreciate it.
>
> "Arvin Meyer [MVP]" wrote:
>
>> Since you can do this in a form or query (or even a report) there is no 
>> need
>> to store the result. In a query use an alias column:
>>
>> Grade: AVG([Grade1]+[Grade2])
>>
>> in a form or report, set the controlsource of the Grade textbox to:
>>
>> =AVG([Grade1]+[Grade2])
>> -- 
>> Arvin Meyer, MCP, MVP
>> http://www.datastrat.com
>> http://www.mvps.org/access
>> http://www.accessmvp.com
>>
>>
>> "Kit"  wrote in message
>> news:72D70EBB-EBC4-4B89-859F-9081AAD3D52F@microsoft.com...
>> > Hi,
>> >
>> > I received a reply that my question on calculating averages had been
>> > answered, when I click on the link for the answer, it was blank. 
>> > Please
>> > respond by to my question.
>> >
>> > Can this calculation of averages be done from a form?
>> >
>> > Form Name is Benton
>> > I have three fields
>> > field one is "grade"
>> > field two is "grade1"
>> > field three is "grade2"
>> >
>> > I want the average of "grade1" and "grade2" to show in the "grade" 
>> > field.
>> >
>> > Can this be done with a form only, if not is there a way I can create a
>> > macro, each time I try to create a macro, I only get the pre-defined
>> > actions.
>> >
>> > Thanks for any help you can give me.
>>
>>
>>
date: Sun, 6 Jul 2008 23:14:51 -0400   author:   Arvin Meyer [MVP]

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us