I have an application in which I have defined a query, and am trying to execute it using querydefs and parameters (The code follows below). If I open the query in design view, and manually enter the selection criteria, I receive the correct results, but, when I try to run the query from code passing the criteria from a form, I keep getting a data type mismatch error. I've checked the field names and types, and all seems to be ok.
Does anyone have any suggestions?
Dim docName As String
Dim ctl As control
Dim blnValid As Boolean
Dim dbs As Database
Dim qdf As QueryDef
Dim prm As Parameter
Dim tdf As TableDef
Dim lngCount As Long
Dim NewName As String
Set dbs = CurrentDb()
dbs.Execute ("DELETE * FROM " & conWorkTable & ";"
Select Case fraAddressType
Case 1 ' BillWho = "B"
If fraCriteria = 1 Then
Set qdf = dbs.QueryDefs![MailMerge -- Owner Account]
End If
Case 2 ' BillWho = "S"
If fraCriteria = 1 Then
Set qdf = dbs.QueryDefs![MailMerge -- Owner and Service Book]
End Select
For Each prm In qdf.Parameters
prm.value = Eval(prm.Name)
Next prm
qdf.Execute
qdf.Close
Does anyone have any suggestions?
Dim docName As String
Dim ctl As control
Dim blnValid As Boolean
Dim dbs As Database
Dim qdf As QueryDef
Dim prm As Parameter
Dim tdf As TableDef
Dim lngCount As Long
Dim NewName As String
Set dbs = CurrentDb()
dbs.Execute ("DELETE * FROM " & conWorkTable & ";"
Select Case fraAddressType
Case 1 ' BillWho = "B"
If fraCriteria = 1 Then
Set qdf = dbs.QueryDefs![MailMerge -- Owner Account]
End If
Case 2 ' BillWho = "S"
If fraCriteria = 1 Then
Set qdf = dbs.QueryDefs![MailMerge -- Owner and Service Book]
End Select
For Each prm In qdf.Parameters
prm.value = Eval(prm.Name)
Next prm
qdf.Execute
qdf.Close