-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Instead of using the Form reference in the query, you'll have to
dynamically create the SQL string in VBA. E.g.:
If not IsNull(Me!cmbOp ) Then
strWhere = strWhere & " Like "'*" & Me!cmbOp & "*'"
End If
If Not IsNull(me!cmbSu b) Then
strWhere = strWhere & " Like '*" & Me!cmbSub & "*'"
End If
If Len(strWhere)>0 Then
strSQL = strSQL & strWhere
End If
'.... then put the SQL string into a QueryDef
' CurrentDb.Query Defs("myQuery") .SQL = strSQL
' or get a recordset
set rs = db.openrecordse t(strSQL)
.... etc. ...
--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQdmXzoechKq OuFEgEQIwewCglM vI0jz2XkZDnGbNY 8EV+HFaxNAAoIUp
9H5O1Rz61UstPjJ bspkFMynn
=+Rkj
-----END PGP SIGNATURE-----
jonhanks wrote:
I'm trying to search by form a field in a table called 'subject' via
two combo boxes on a form. In the query I have the following criteria
in the 'Subject' field:
(Like "*" & [Forms]![frmFind]![cmbOp] & "*") Or (Like "*" &
[Forms]![frmFind]![cmbSub] & "*")
This seems to work fine untill I leave either [cmbOp] blank, or
[cmbSub] blank - at which point it returns ALL records with no blank
Subject field. Any ideas?