R
Robert Grazia
Hi All,
I have recently inherited an application and working to fix some broken
parts. One of these things is a query that pulls data in from a function.
Here is the function:
Code
--------------------------------------------------------------------------------
Hi All,
I have recently inherited an application and working to fix some broken
parts. One of these things is a query that pulls data in from a function.
Here is the function:
Code
--------------------------------------------------------------------------------
Public Function BuildRenewalServices(intRUID As Integer, intLicenseNumber As
Integer, dtmRenewalDate As Date) As String Dim strServices As String
Dim rst As ADODB.Recordset Dim strSQL As String Set rst = New
ADODB.Recordset strSQL = "SELECT * FROM
qry_LTR_MergeLetters_SelectSvcs WHERE " & _
"(((qry_LTR_MergeLetters_SelectSvcs.RUID)=" & intRUID & ") AND
((qry_LTR_MergeLetters_SelectSvcs.dtm_RenewalReceived)=#" & _
dtmRenewalDate & "#) AND ((qry_LTR_MergeLetters_SelectSvcs.LicenseNumber)= "
& intLicenseNumber & "))" strServices = "" rst.Open strSQL,
CurrentProject.Connection, adOpenForwardOnly, adLockOptimistic With
rst Do Until .EOF If strServices = "" Then
strServices = rst.Fields(2) Else strServices =
strServices & ", " & rst.Fields(2) End If .MoveNext
Loop End With BuildRenewalServices = strServices End Functio
--------------------------------------------------------------------------------
The query itself has the following fields (relevant ones only):
RUID
LicenseNumber
dtm_RenewalReceived
:::Other Info:::
Another field in this query calls the above function like so:
ListServices: BuildRenewalServices([RUID], [LicenseNumber],
[dtm_RenewalReceived])
Ok, so that's the process in a nutshell.
Now here's my problem... whenever this query is run, I receive the "Data
type mismatch in criteria expression" error.
I have no idea why this is occuring. I have placed "Debug.Print strSQL" and
"Debug.Print strServices" in my code and everything turns up clean in the
immediate window.
Any ideas regarding this problem?
Robert
--------------------------------------------------------------------------------
The query itself has the following fields (relevant ones only):
RUID
LicenseNumber
dtm_RenewalReceived
:::Other Info:::
Another field in this query calls the above function like so:
ListServices: BuildRenewalServices([RUID], [LicenseNumber],
[dtm_RenewalReceived])
Ok, so that's the process in a nutshell.
Now here's my problem... whenever this query is run, I receive the "Data
type mismatch in criteria expression" error.
I have no idea why this is occuring. I have placed "Debug.Print strSQL" and
"Debug.Print strServices" in my code and everything turns up clean in the
immediate window.
Any ideas regarding this problem?
Robert
I have recently inherited an application and working to fix some broken
parts. One of these things is a query that pulls data in from a function.
Here is the function:
Code
--------------------------------------------------------------------------------
Hi All,
I have recently inherited an application and working to fix some broken
parts. One of these things is a query that pulls data in from a function.
Here is the function:
Code
--------------------------------------------------------------------------------
Public Function BuildRenewalServices(intRUID As Integer, intLicenseNumber As
Integer, dtmRenewalDate As Date) As String Dim strServices As String
Dim rst As ADODB.Recordset Dim strSQL As String Set rst = New
ADODB.Recordset strSQL = "SELECT * FROM
qry_LTR_MergeLetters_SelectSvcs WHERE " & _
"(((qry_LTR_MergeLetters_SelectSvcs.RUID)=" & intRUID & ") AND
((qry_LTR_MergeLetters_SelectSvcs.dtm_RenewalReceived)=#" & _
dtmRenewalDate & "#) AND ((qry_LTR_MergeLetters_SelectSvcs.LicenseNumber)= "
& intLicenseNumber & "))" strServices = "" rst.Open strSQL,
CurrentProject.Connection, adOpenForwardOnly, adLockOptimistic With
rst Do Until .EOF If strServices = "" Then
strServices = rst.Fields(2) Else strServices =
strServices & ", " & rst.Fields(2) End If .MoveNext
Loop End With BuildRenewalServices = strServices End Functio
--------------------------------------------------------------------------------
The query itself has the following fields (relevant ones only):
RUID
LicenseNumber
dtm_RenewalReceived
:::Other Info:::
Another field in this query calls the above function like so:
ListServices: BuildRenewalServices([RUID], [LicenseNumber],
[dtm_RenewalReceived])
Ok, so that's the process in a nutshell.
Now here's my problem... whenever this query is run, I receive the "Data
type mismatch in criteria expression" error.
I have no idea why this is occuring. I have placed "Debug.Print strSQL" and
"Debug.Print strServices" in my code and everything turns up clean in the
immediate window.
Any ideas regarding this problem?
Robert
--------------------------------------------------------------------------------
The query itself has the following fields (relevant ones only):
RUID
LicenseNumber
dtm_RenewalReceived
:::Other Info:::
Another field in this query calls the above function like so:
ListServices: BuildRenewalServices([RUID], [LicenseNumber],
[dtm_RenewalReceived])
Ok, so that's the process in a nutshell.
Now here's my problem... whenever this query is run, I receive the "Data
type mismatch in criteria expression" error.
I have no idea why this is occuring. I have placed "Debug.Print strSQL" and
"Debug.Print strServices" in my code and everything turns up clean in the
immediate window.
Any ideas regarding this problem?
Robert