Advertisement
Advertisement
| 02.27.2008 at 03:49PM PST, ID: 23198955 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 02.27.2008 at 04:02PM PST, ID: 20999993 |
| 02.27.2008 at 04:31PM PST, ID: 21000198 |
| 02.27.2008 at 07:52PM PST, ID: 21001099 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: |
'===============================================================
' The following function MovAvg computes moving averages based on
' a table with a multiple-field primary key.
'===============================================================
Function MovAvg(ItemNbr, startDate, period As Integer)
Dim rst As DAO.Recordset
Dim sql As String
Dim ma As Currency
Dim n As Integer
sql = "Select * from [Weekly Sales by type All Items] "
sql = sql & "where ItemNbr = " & ItemNbr
sql = sql & " and [Week Ending] <= #" & startDate & "#"
sql = sql & " order by [Week Ending]"
Set rst = CurrentDb.OpenRecordset(sql)
rst.MoveLast
For n = 0 To period - 1
If rst.BOF Then
MovAvg = 0
Exit Function
Else
ma = ma + rst.Fields("Sales$")
End If
rst.MovePrevious
Next n
rst.Close
MovAvg = ma / period
End Function
|
| 02.28.2008 at 07:52AM PST, ID: 21004907 |
| 02.28.2008 at 08:23AM PST, ID: 21005346 |
| 02.28.2008 at 10:32AM PST, ID: 21006655 |
| 02.28.2008 at 12:35PM PST, ID: 21007760 |
| 02.28.2008 at 01:07PM PST, ID: 21008072 |
| 02.28.2008 at 03:00PM PST, ID: 21009142 |
| 02.28.2008 at 03:04PM PST, ID: 21009169 |
| 02.29.2008 at 07:16AM PST, ID: 21013918 |
| 02.29.2008 at 01:34PM PST, ID: 21017827 |
| 02.29.2008 at 07:18PM PST, ID: 21019706 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: |
Function DateSQL(pvarDate) As String
' Create a string representation suitable for SQL
' Jet accepts only US dates or ISO dates
If IsNull(pvarDate) Then
DateSQL = "Null"
Else
DateSQL = Format(pvarDate, "\#yyyy\-mm\-dd\#")
End If
End Function
Sub ComputeAllAverages()
' Calculate moving averages for sales and units in the weekly sales table
' A single total query is used to calculate both for each record
Const SALES = "Weekly Sales by type All Items"
Const SCOPE = 8 ' nb of weeks in moving average
Dim mdb As DAO.Database
Dim recMain As DAO.Recordset
Dim recTot As DAO.Recordset
Dim strSQL As String
Set mdb = CurrentDb
Set recMain = mdb.OpenRecordset(SALES, dbOpenDynaset)
Do Until recMain.EOF
' build query
strSQL _
= " SELECT" _
& " Count(*) AS Nb," _
& " Sum([Sales $]) AS TotalSales," _
& " Sum([Sales Units]) AS TotalUnits" _
& " FROM (" _
& " SELECT TOP " & SCOPE & " [Sales $], [Sales Units]" _
& " FROM [" & SALES & "]" _
& " WHERE ItmNbr = " & recMain!ItmNbr _
& " And [Week Ending] <= " & DateSQL(recMain![Week Ending]) _
& " And Promo Is Null" _
& " ORDER BY [Week Ending] Desc" _
& " ) AS WSAI"
Set recTot = mdb.OpenRecordset(strSQL, dbOpenSnapshot)
' store results
recMain.Edit
' If recTot!Nb <> SCOPE Then ' strict moving average
If recTot!Nb > 0 Then ' lenient moving average
recMain!AvgWklyDollars = Null
recMain!AvgWklyUnits = Null
Else
recMain!AvgWklyDollars = recTot!TotalSales / recTot!Nb
recMain!AvgWklyUnits = recTot!TotalUnits / recTot!Nb
End If
recMain.Update
recMain.MoveNext
Loop
End Sub
|
| 03.03.2008 at 09:53AM PST, ID: 21033903 |
| 03.03.2008 at 02:27PM PST, ID: 21036403 |
| 03.04.2008 at 08:32AM PST, ID: 21042467 |
| 03.04.2008 at 09:21AM PST, ID: 21042917 |