Hi, another problem that I dont know how to solve, please help!!! I have a QUERY called qry_ALL, a FORM where the user puts in data to find records. I have 9 text boxes for user input in the FORM but of course not all text boxes will be filled in. The parameter value is null and I expect it returns the value even if it's null, but no record is being returned at all. I have put Is Null under other criteria of QUERY qry_ALL but still doesnt retrieve any records, please help. Below is the code:
Dim qryQuote As DAO.QueryDef
Dim rec As DAO.Recordset
Set qryQuote = CurrentDb.QueryDefs("qry_ALL")
If Not IsNull(Me.x) Or Me.x <> "" Then qryQuote.Parameters!test1 = Me.x
If Not IsNull(Me.y) Or Me.y <> "" Then qryQuote.Parameters!test2 = Me.y
If Not IsNull(Me.z) Or Me.z <> "" Then qryQuote.Parameters!test3 = Me.z
If Not IsNull(Me.a) Or Me.a <> "" Then qryQuote.Parameters!test4 = Me.a
If Not IsNull(Me.b) Or Me.b <> "" Then qryQuote.Parameters!test5 = Me.b
If Not IsNull(Me.c) Or Me.c <> "" Then qryQuote.Parameters!test6 = Me.c
If Not IsNull(Me.d) Or Me.d <> "" Then qryQuote.Parameters!test7 = Me.d
If Not IsNull(Me.e) Or Me.e <> "" Then qryQuote.Parameters!test8 = Me.e
If Not IsNull(Me.f) Or Me.f <> "" Then qryQuote.Parameters!test9 = Me.f
Set rec = qryQuote.OpenRecordset()
If rec.RecordCount <> 0 Then
Set Me!lstResult.Recordset = rec
End If
Regards,
Sandra
Dim qryQuote As DAO.QueryDef
Dim rec As DAO.Recordset
Set qryQuote = CurrentDb.QueryDefs("qry_ALL")
If Not IsNull(Me.x) Or Me.x <> "" Then qryQuote.Parameters!test1 = Me.x
If Not IsNull(Me.y) Or Me.y <> "" Then qryQuote.Parameters!test2 = Me.y
If Not IsNull(Me.z) Or Me.z <> "" Then qryQuote.Parameters!test3 = Me.z
If Not IsNull(Me.a) Or Me.a <> "" Then qryQuote.Parameters!test4 = Me.a
If Not IsNull(Me.b) Or Me.b <> "" Then qryQuote.Parameters!test5 = Me.b
If Not IsNull(Me.c) Or Me.c <> "" Then qryQuote.Parameters!test6 = Me.c
If Not IsNull(Me.d) Or Me.d <> "" Then qryQuote.Parameters!test7 = Me.d
If Not IsNull(Me.e) Or Me.e <> "" Then qryQuote.Parameters!test8 = Me.e
If Not IsNull(Me.f) Or Me.f <> "" Then qryQuote.Parameters!test9 = Me.f
Set rec = qryQuote.OpenRecordset()
If rec.RecordCount <> 0 Then
Set Me!lstResult.Recordset = rec
End If
Regards,
Sandra