Advertisement
Advertisement
| 07.23.2008 at 02:07AM PDT, ID: 23587754 |
|
[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! |
||
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: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: |
Dim SalesRpt As Recordset 'sum of sales fees by month , by rep
Dim Letters As Recordset 'All letters + date written
'
Dim MthNos As Integer
Dim Rep1 As Single
Dim Rep2 As Single
Dim Rep3 As Single
Dim Rep4 As Single
Dim RepOther As Single
'
'
Dim X As Integer
Dim Y As Integer
'
Dim ClientId As Integer
Dim Fromdate As String ' date letter was written
Dim Todate As String 'until 40 days after last letter was written
'clear salesrpt
For X = 1 To UBound(SalesRpt, 1)
For Y = 1 To UBound(SalesRpt, 2)
SalesRpt(X, Y) = ""
Next
Next
'
'select LETTERS records
Set Letters = CURDB.OpenRecordset("Select * from LETTERS where Isdate(PC_Letterdate) = true order by (PC_Letterdate) asc", dbOpenDynaset)
Letters.MoveFirst
'********************************************************************
'Loop through Letters & calculate sales within 40 days of each correspondence
'********************************************************************
Do While Not Letters.EOF
'ClientId
ClientId = Letters("PC_ClientID")
'Fromdate
Fromdate = Letters("PC_LetterDate")
'ToDate - + 40 days
Todate = DateAdd("d", 40, Fromdate)
'****original report (total sales , by month , by rep )******
'Adapted to only select sales to a client within 40days of a letter (ie fromdate and todate)
SQL = ""
SQL = "Select Year([SH_ServDate]) as Yr, Month([SH_ServDate]) as Mth, [SH_RepID] as Doctor"
SQL = SQL & ", first(DateDiff('m', Now, [SH_ServDate])) as MthNr"
SQL = SQL & ", Sum([SH_Fee]) as SalesFee"
SQL = SQL & " from SALES_HISTORY inner join LETTERS"
SQL = SQL & " on SALES_HISTORY.[SH_ClientId] = LETTERS.[PC_ClientID]"
SQL = SQL & " where [SH_ServDate] > datevalue('" & Fromdate & "')"
SQL = SQL & " and [SH_ServDate] < datevalue('" & Todate & "')"
SQL = SQL & " and [SH_ClientId] = " & ClientId
SQL = SQL & " and [SH_ItemNos] in ('21','23','53','54','721','723','725','2620','2517','10991','10993','10990')"
SQL = SQL & " group by Year([SH_ServDate]), Month([SH_ServDate]), SH_RepID"
SQL = SQL & " order by Year([SH_ServDate]), Month([SH_ServDate]), SH_RepID"
':
Set SalesRpt = CURDB.OpenRecordset(SQL, dbOpenSnapshot)
DoEvents
'
On Error Resume Next
SalesRpt.MoveLast
If SalesRpt.RecordCount = 0 Then
'move to next letter
Else
SalesRpt.MoveFirst
End If
MthNos = SalesRpt("MthNr")
'place sales generated by this letter into array. Arranged (by rep, by month)
Do
If MthNos = SalesRpt("MthNr") Then
If InStr(1, UCase$(SalesRpt("Rep")), "REP1") > 0 Then
Rep1 = Rep1 + SalesRpt("SalesFee")
ElseIf InStr(1, UCase$(SalesRpt("Rep")), "REP2") > 0 Then
Rep2 = Rep2 + SalesRpt("SalesFee")
ElseIf InStr(1, UCase$(SalesRpt("Rep")), "REP3") > 0 Then
Rep3 = Rep3 + SalesRpt("SalesFee")
ElseIf InStr(1, UCase$(SalesRpt("Rep")), "REP4") > 0 Then
Rep4 = Rep4 + SalesRpt("SalesFee")
Else
RepOther = RepOther + SalesRpt("SalesFee")
End If
'
End If
'
'keep/print previous months totals in array
SalesRpt((MthNos + 25), 1) = CStr(Format(Rep1, "Currency"))
SalesRpt((MthNos + 25), 2) = CStr(Format(Rep2, "Currency"))
SalesRpt((MthNos + 25), 3) = CStr(Format(Rep3, "Currency"))
SalesRpt((MthNos + 25), 4) = CStr(Format(Rep4, "Currency"))
SalesRpt((MthNos + 25), 5) = CStr(Format(RepOther, "Currency"))
'print on screen
IMPList.AddItem MthNos & vbTab _
& CStr(Format(Rep1, "Currency")) & vbTab & vbTab _
& CStr(Format(Rep2, "Currency")) & vbTab & vbTab _
& CStr(Format(Rep3, "Currency")) & vbTab & vbTab _
& CStr(Format(Rep4, "Currency")) & vbTab & vbTab _
& CStr(Format(RepOther, "Currency"))
'reset totals for new month
MthNos = SalesRpt("MthNr")
Rep1 = 0
Rep2 = 0
Rep3 = 0
Rep4 = 0
RepOther = 0
Extra40 = 0
'add sales to existing array
If MthNos = SalesRpt("MthNr") Then
If InStr(1, UCase$(SalesRpt("Rep")), "REP1") > 0 Then
Rep1 = Rep1 + SalesRpt("SalesFee")
ElseIf InStr(1, UCase$(SalesRpt("Rep")), "REP2") > 0 Then
Rep2 = Rep2 + SalesRpt("SalesFee")
ElseIf InStr(1, UCase$(SalesRpt("Rep")), "REP3") > 0 Then
Rep3 = Rep3 + SalesRpt("SalesFee")
ElseIf InStr(1, UCase$(SalesRpt("Rep")), "REP4") > 0 Then
Rep4 = Rep4 + SalesRpt("SalesFee")
Else
RepOther = RepOther + SalesRpt("SalesFee")
End If
End If
SalesRpt.MoveNext
'
Loop Until SalesRpt.EOF 'gets sales totals by month for current letter
'keep totals in array
SalesRpt((MthNos + 25), 1) = CStr(Format(Rep1, "Currency"))
SalesRpt((MthNos + 25), 2) = CStr(Format(Rep2, "Currency"))
SalesRpt((MthNos + 25), 3) = CStr(Format(Rep3, "Currency"))
SalesRpt((MthNos + 25), 4) = CStr(Format(Rep4, "Currency"))
SalesRpt((MthNos + 25), 5) = CStr(Format(RepOther, "Currency"))
'print on screen
IMPList.AddItem MthNos & vbTab _
& CStr(Format(Rep1, "Currency")) & vbTab & vbTab _
& CStr(Format(Rep2, "Currency")) & vbTab & vbTab _
& CStr(Format(Rep3, "Currency")) & vbTab & vbTab _
& CStr(Format(Rep4, "Currency")) & vbTab & vbTab _
& CStr(Format(RepOther, "Currency"))
Letters.MoveNext
Loop 'moves to next letter
SalesRpt.Close
DoEvents
|