P
PatK
Hoping someone might be able to help. I have the following Function that I
have used in excel 2007 (and it works fine), that I am trying to now use in
MS Access. Basically you pass a date string to the function and it returns a
fiscal year quarter (our fiscal years starts on Nov 1). The code, when runs,
gets a type mismatch whenever it gets to one of the lines coded (entire
function at bottom):
FiscalQtr = "FY" & Right(DatePart("yyyy", inDate + yeardays), 2) & strQtr
When I hover my mouse over inDate, I will see dates like I would expect
("11/14/2009"). All these fields are string, ALTHO when I used the
FiscalQtr() function in a query, the date I am passing is being converted
from a date format, to a string format, and that seems to be working fine.
Ie, in my query I have (design view), the following:
FiscalQ: fiscalqtr(Format$([sharepointlistname].[Prod (Month
Start)],'mm/dd/yyyy'))
Before I inserted the FiscalQtr function code, ie, had on they formatted
text, that output exactly what I expected. Here is the entire code.
Ideas? PatK
Option Compare Database
Function FiscalQtr(inDate As String) As String
Dim strQtr As String
Dim mm As Integer
Dim yeardays As Integer
If (DatePart("yyyy", inDate)) Mod 4 = 0 Then
yeardays = 364
Else
yeardays = 365
End If
strQtr = ""
Select Case DatePart("m", inDate)
Case 11, 12, 1
strQtr = " Q1"
Case 2, 3, 4
strQtr = " Q2"
Case 5, 6, 7
strQtr = " Q3"
Case 8, 9, 10
strQtr = " Q4"
Case Else
strQtr = ""
End Select
If strQtr <> " Q1" Then
FiscalQtr = "FY" & Right(DatePart("yyyy", inDate), 2) & strQtr
Else
If DatePart("m", inDate) <> 1 Then
Debug.Print Right(DatePart("yyyy", inDate + yeardays), 2)
FiscalQtr = "FY" & Right(DatePart("yyyy", inDate + yeardays), 2) &
strQtr
Else
FiscalQtr = "FY" & Right(DatePart("yyyy", inDate), 2) & strQtr
End If
End If
End Function
have used in excel 2007 (and it works fine), that I am trying to now use in
MS Access. Basically you pass a date string to the function and it returns a
fiscal year quarter (our fiscal years starts on Nov 1). The code, when runs,
gets a type mismatch whenever it gets to one of the lines coded (entire
function at bottom):
FiscalQtr = "FY" & Right(DatePart("yyyy", inDate + yeardays), 2) & strQtr
When I hover my mouse over inDate, I will see dates like I would expect
("11/14/2009"). All these fields are string, ALTHO when I used the
FiscalQtr() function in a query, the date I am passing is being converted
from a date format, to a string format, and that seems to be working fine.
Ie, in my query I have (design view), the following:
FiscalQ: fiscalqtr(Format$([sharepointlistname].[Prod (Month
Start)],'mm/dd/yyyy'))
Before I inserted the FiscalQtr function code, ie, had on they formatted
text, that output exactly what I expected. Here is the entire code.
Ideas? PatK
Option Compare Database
Function FiscalQtr(inDate As String) As String
Dim strQtr As String
Dim mm As Integer
Dim yeardays As Integer
If (DatePart("yyyy", inDate)) Mod 4 = 0 Then
yeardays = 364
Else
yeardays = 365
End If
strQtr = ""
Select Case DatePart("m", inDate)
Case 11, 12, 1
strQtr = " Q1"
Case 2, 3, 4
strQtr = " Q2"
Case 5, 6, 7
strQtr = " Q3"
Case 8, 9, 10
strQtr = " Q4"
Case Else
strQtr = ""
End Select
If strQtr <> " Q1" Then
FiscalQtr = "FY" & Right(DatePart("yyyy", inDate), 2) & strQtr
Else
If DatePart("m", inDate) <> 1 Then
Debug.Print Right(DatePart("yyyy", inDate + yeardays), 2)
FiscalQtr = "FY" & Right(DatePart("yyyy", inDate + yeardays), 2) &
strQtr
Else
FiscalQtr = "FY" & Right(DatePart("yyyy", inDate), 2) & strQtr
End If
End If
End Function