[AccessD] Solved ( I think) Trimmean Function - How to in Access

Mark A Matte markamatte at hotmail.com
Wed Apr 12 09:33:13 CDT 2006


Julie,

I read the other email...were you  trying to calculate the mean...or just 
put the remaining records in the temp table?  If you wanted the other 
records you would put your 'add the record" code in the following IF 
statement:If Num > Trim And Num < MaxTrim Then

Hope it helps...

Mark A. Matte


>From: "Julie Reardon-Taylor" <prosoft6 at hotmail.com>
>Reply-To: Access Developers discussion and problem 
>solving<accessd at databaseadvisors.com>
>To: accessd at databaseadvisors.com
>Subject: Re: [AccessD] Solved ( I think) Trimmean Function - How to in 
>Access
>Date: Wed, 12 Apr 2006 10:11:34 -0400
>
>Okay.  I think this is now working.  Here is the code below:
>
>Private Sub Command0_Click()
>Dim Per
>Per = 0.2
>Dim db As DAO.Database
>Set db = CurrentDb()
>    Dim GroupRst As DAO.Recordset
>    Set GroupRst = db.OpenRecordset("SELECT tblMonthlyProfile.Profile FROM
>tblMonthlyProfile GROUP BY tblMonthlyProfile.Profile;", DB_OPEN_DYNASET)
>    Dim GroupName As Field
>    Set GroupName = GroupRst!Profile
>    Do Until GroupRst.EOF
>        Dim MyRst As DAO.Recordset
>        Set MyRst = db.OpenRecordset("SELECT tblMonthlyProfile.id,
>tblMonthlyProfile.Profile, tblMonthlyProfile.Unit, tblMonthlyProfile.Cmonth
>FROM tblMonthlyProfile WHERE (((tblMonthlyProfile.Profile) = " & GroupName 
>&
>")) ORDER BY tblMonthlyProfile.profile;", DB_OPEN_DYNASET)
>        Dim List As Field
>        Set List = MyRst!CMonth
>        Dim Counter
>        Counter = MyRst.RecordCount
>        Dim Trim
>        Dim MaxTrim
>        Dim Div
>
>        If InStr(1, Int(Counter * Per) / 2, ".") = 0 Then
>           Trim = Int(Counter * Per) / 2
>            MaxTrim = Counter - Int(Counter * Per) / 2 + 1
>            Div = Counter - Int(Counter * Per)
>        Else
>            Trim = (Int(Counter * Per) - 1) / 2
>            MaxTrim = Counter - (Int(Counter * Per) - 1) / 2 + 1
>            Div = Counter - Int(Counter * Per) + 1
>        End If
>
>
>
>        Dim ListSum
>        ListSum = 0
>        Dim Num
>        Num = 0
>        Do Until MyRst.EOF
>
>             Num = Num + 1
>             If Num > Trim And Num < MaxTrim Then
>                 ListSum = ListSum + List
>               Else
>             ListSum = ListSum
>        End If
>
>             MyRst.MoveNext
>       Loop
>                 Set Rst = db.OpenRecordset("tblTempData", dbOpenDynaset)
>                 Rst.AddNew
>                 Rst!CMonth = (ListSum / Div)
>                 Rst!Profile = GroupName
>                 Rst!Unit = Div
>                 Rst!ID = ListSum
>                 Rst.Update
>
>
>    GroupRst.MoveNext
>    Loop
>
>End Sub
>
>
>
>Julie Reardon-Taylor
>PRO-SOFT OF NY, INC.
>44 Public Square Suite #5
>Watertown, NY 13601
>Phone: 315.785.0319
>Fax: 315.785.0323
>www.pro-soft.net
>NYS IT Services Contract CMT026A
>NYS Certified Woman-Owned Business
>
>
>--
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com





More information about the AccessD mailing list