April15Hater
Accountant
- Local time
- Today, 11:23
- Joined
- Sep 12, 2008
- Messages
- 349
Hello all-
Having some trouble with some of my code below.
There are times where the strAccountPrefix_LOB variable is either blank or 2 characters. Because it is being dimensioned as 2 characters, when it is blank, it gives me spaces. The spaces return an asc() of 32, but the spaces will not go away using the replace command. Any help is appreciated.
FWIW, I set the string length for speed purposes because this is going to be a user defined function in a query. I have it as a string because sometimes it will be alphanumeric.
Having some trouble with some of my code below.
There are times where the strAccountPrefix_LOB variable is either blank or 2 characters. Because it is being dimensioned as 2 characters, when it is blank, it gives me spaces. The spaces return an asc() of 32, but the spaces will not go away using the replace command. Any help is appreciated.
FWIW, I set the string length for speed purposes because this is going to be a user defined function in a query. I have it as a string because sometimes it will be alphanumeric.
Code:
Function RetentionPeriod(strAccountPrefix As String, _
strCenterPrefix As String, _
Optional strDivision As String, _
Optional strLedger As String) As Double
'Standard dimensions
Dim strCenterSearch As String
Dim strSearchString As String
Dim strAccountSearch As String
Dim intAccountPrefix_Len As Double
Dim strRetention As String
Dim intAccountLevel As Integer
Dim intCenterLevel As Integer
'AccountPrefix dimensions
Dim strAccountPrefix_ClassCode As String * 1
Dim strAccountPrefix_GroupCode As String * 1
Dim strAccountPrefix_DetailCode As String * 3
Dim strAccountPrefix_LOB As String * 2
'CenterPrefix dimensions
Dim strCenterPrefix_Division As String * 2
Dim strCenterPrefix_LineofBusiness As String * 1
Dim strCenterPrefix_Marketing As String * 2
Dim strCenterPrefix_Other As String * 3
'Account Number Processing------------------------------------------------------------------------------
'Define Standard Variables
strAccountPrefix = Trim(Left(strAccountPrefix, 7))
strCenterPrefix = Trim(Left(strCenterPrefix, 8))
intAccountPrefix_Len = Len(strAccountPrefix)
'Break out account for ClassCode, GroupCode, DetailCode, and LOB
strAccountPrefix_ClassCode = Replace(Mid(strAccountPrefix, 1, 1), " ", "") '1 position
strAccountPrefix_GroupCode = Replace(Mid(strAccountPrefix, 2, 1), " ", "") '2 position
strAccountPrefix_DetailCode = Replace(Mid(strAccountPrefix, 3, 3), " ", "") '3-5 position
strAccountPrefix_LOB = Replace(Mid(strAccountPrefix, 6, 2), Chr(32), "") '6-7 position