Re: Average within a record
- From: Darlahood <Darlahood@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 12 Jul 2005 12:04:05 -0700
Oh Goodness!~
I just found out that we need the avg to be used in a query, and the
avgField needs to be joined to the table...When we do a query on the data it
isnt "bound" to the table and we dont get any data...
I tried making an event for the avg in the code editor but to no avail...
Ho boy anymore help would be greatly appreciated Thank you very much!
--
Darlahood
"Klatuu" wrote:
> #1. See my previous post. This is because you are getting a divide by 0
> when all 3 fields are empty.
> #2. Yes, but you will still get the problem in #1. You can use the function
> I posted earlier (here it is again) in place of the formula as your control
> source. It will avoid the divide by 0 problem.
>
> Function CalcAvg(sngAmt1, sngAmt2, sngAmt3) As Single
> Dim lngDivisor as Long
> lngDivisor = 3
> If IsNull(sngAmt1) Then lngDivisor = 2
> If IsNull(sngAmt2) Then lngDivisor = 1
> If IsNull(sngAmt3) Then lngDivisor = 0
> If lngDivisor > 0 Then
> CalcAvg = (Nz(sngAmt1,0) + Nz(sngAmt2,0) + Nz(sngAmt3,0))/lngDivisor
> End If
> End Function
>
> #3. Great, I hoped that would work.
>
> "Darlahood" wrote:
>
> > You people are Gods!!
> > Thank you so much for your help. Nobody has been able to help me with this.
> >
> > now for the questions:
> > #1. The avgField displays #Num! when the fields are blank. When we have 0 in
> > the fields it displays 0.
> >
> > #2. To implement the return 0, do I modify the current code of:
> > =(Nz([Press#1Moisture]))/(Abs(Not IsNull([Press#1Moisture])))
> > To Read:
> > =(Nz([Press#1Moisture],0))/(Abs(Not IsNull([Press#1Moisture])))
> >
> > #3. It updates when I click to another field.
> >
> > Thanks So Much!!
> >
> >
> > --
> > Darlahood
> >
> >
.
- Follow-Ups:
- Re: Average within a record
- From: Klatuu
- Re: Average within a record
- References:
- Average within a record
- From: Darlahood
- RE: Average within a record
- From: Klatuu
- RE: Average within a record
- From: Darlahood
- RE: Average within a record
- From: Darlahood
- Re: Average within a record
- From: Al Camp
- Re: Average within a record
- From: Klatuu
- Re: Average within a record
- From: Darlahood
- Re: Average within a record
- From: Klatuu
- Average within a record
- Prev by Date: RE: Go to New record on 2nd subform
- Next by Date: Re: radio buttons
- Previous by thread: Re: Average within a record
- Next by thread: Re: Average within a record
- Index(es):