Chapter 8 VBA 2000: frmCriteria not working.
Hi,
I have tried to apply the following code from the book to my database.
I have managed to build successfully the tblResults. But when I select a criteria from the frmCriteria, I get the following runtime error: 3464: Data type mismatch in criteria expression.
The debugger is pointing at the following code:
Function BuildResultsTable(strSQL As String, _
strTableName As String, _
strRecordsAffected As String)
Dim db As Database
Dim qdfAction As QueryDef
Set db = CurrentDb
On Error Resume Next
db.TableDefs.Delete strTableName
On Error GoTo 0
strSQL = Replace(strSQL, " FROM ", " INTO " & strTableName & " FROM ")
Set qdfAction = db.CreateQueryDef("", strSQL)
qdfAction.Execute dbFailOnError
strRecordsAffected = qdfAction.RecordsAffected
qdfAction.Close
BuildResultsTable = True
End Function
My table contains a Text data type as Primary key, which I have tried to addapt by changing the lngRecordsAffected from the book to strRecordsAffected, making sure that I would be consistent with it. Was it a mistake?
I am quite confused and would really appreciate some help.
Many Thanks,
Chris
|