qd.Parameters("CrimeType") = "Like '" & strCrime &'" add the ' in the
statement. This is a string variable treat it like a string and not a
int or long.
-----Original Message-----
From: professional vb [SMTP:pro_vb@p...]
Sent: Saturday, January 27, 2001 3:26 PM
To: professional vb
Subject: [pro_vb] Parameter Queries
I'm trying to pass parameters to a compiled queries in
my Jet database and then open the Parameter Query in
datasheet view without being prompted for the
arguments. I got the idea for the below code from an
Access 97 book. But I can't get it to work! I get an
Data Type Mismatch error message on the last line. I
see VB's point. I'm trying to assign a recordset to a
querydef. But, that is what was in the book. Can
anyone tell me how to make this thing work?
'------------------------------------------------------
----------------------
Private Sub cmdExample2_Click()
Dim rs As Recordset
Set rs = Example2("06*", "1*")
End Sub
'------------------------------------------------------
--------------------------
Private Function Example2(strCrime As String,
strDisposition As String) As Recordset
Dim qd As QueryDef
Dim db As Database
Set db = CurrentDb()
Set qd = db.QueryDefs("qryExample2")
qd.Parameters("CrimeType") = "Like " & strCrime
qd.Parameters("DispositionType") = "Like " &
strDisposition
Set Example2 = qd.OpenRecordset
End Function
'------------------------------------------------------
----------------------------------
*****
* J. J. Campbell
* Arlington, Virginia
* MailTo:jjcampbell@w...
*****