Statistician
MIS
Wonder if anyone is able to help please (I have scanned through some threads but cannot find a solution).
I have a simple query (using Access 2010) where I've used a vba function to use a date field in the query and return a period value (integer).
When I try to enter something like >1 in the criteria row of the query (against this calculated field), I get an error message stating "Data type mismatch in criteria expression".
So, basically, all I want to be able to do is enter some criteria based on what periods I am interested in to return those records but am unable to.
Any advice/help is appreciated.
The function I am using in the query field is as follows:
Public Function GetPeriod(sentdate As Date) As Integer
Select Case sentdate
Case #1/1/2015# To #1/31/2015#
GetPeriod = 1
Case #1/1/2015# To #2/28/2015#
GetPeriod = 2
Case Else
GetPeriod = 0
End Select
End Function
I have a simple query (using Access 2010) where I've used a vba function to use a date field in the query and return a period value (integer).
When I try to enter something like >1 in the criteria row of the query (against this calculated field), I get an error message stating "Data type mismatch in criteria expression".
So, basically, all I want to be able to do is enter some criteria based on what periods I am interested in to return those records but am unable to.
Any advice/help is appreciated.
The function I am using in the query field is as follows:
Public Function GetPeriod(sentdate As Date) As Integer
Select Case sentdate
Case #1/1/2015# To #1/31/2015#
GetPeriod = 1
Case #1/1/2015# To #2/28/2015#
GetPeriod = 2
Case Else
GetPeriod = 0
End Select
End Function