Maracay said:
Hi Thanks it works, now I have another question, is possible to assign the
logic to a text box and place the text box instead of typing the logic,
because the logic may change overtime and it wont be necesary to change
the
program and for other reasons I would like to try this option.
example
txtLogic = " Province = 'BC' or Province = 'ON' "
Set rst = dbs.OpenRecordset( _
"SELECT * FROM qry_ClientData WHERE " & _
"(txtLogic)")
This doesn't work because I tried, but is the idea of what I want
So long as you are building the SQL statement on the fly, you can do this.
In the example above, you would do it like this:
Set rst = dbs.OpenRecordset( _
"SELECT * FROM qry_ClientData WHERE " & Me.txtLogic)
You might prefer to allow for txtLogic to be blank, indicating no filtering
on the query results. In that case, this might serve:
Dim strWhere As String
strWhere = Me.txtLogic & vbNullString
If Len(strWhere) > 0 Then
strWhere = " WHERE " & strWhere
End If
Set rst = dbs.OpenRecordset( _
"SELECT * FROM qry_ClientData" & strWhere)