Can some one pl help me to save my job

M

Mike Saifie

I have this data access database which I modifed.

In the Search form code I need it to modify code so, it look and match more
then one field. If the record is not in one field then it should go and look
for the second one or third. pl see the code. pl some one hlep me.

Thanks.

Mike
Option Compare Database
Option Explicit

Private Sub Clear_Click()
DoCmd.Close
DoCmd.OpenForm "Search Issues"
End Sub

Private Sub Search_Click()
Const cInvalidDateError As String = "You have entered an invalid date."
Dim strWhere As String
Dim strError As String

strWhere = "1=1"

' If Assigned To
If Not IsNull(Me.AssignedTo) Then
'Create Predicate
strWhere = strWhere & " AND " & "Issues.[Assigned To] = " &
Me.AssignedTo & ""
End If

' If Opened By
If Not IsNull(Me.OpenedBy) Then
'Add the predicate
strWhere = strWhere & " AND " & "Issues.[Opened By] = " &
Me.OpenedBy & ""
End If

' If Status
If Nz(Me.Status) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "Issues.Status = '" & Me.Status &
"'"

' THIS IS WHERE I NEED A CODE SO, IT CAN SEARCH OTHER KEYS IN THE
SAME TABLE?
End If
 
G

Guest

You did not make it clear what you wanted......but........
It sounds like you need some OR clauses which means the whole thing needs to
be in parentheses.

If Nz(Me.Status) <> 0 Then
strWhere = strWhere & " AND (" & "Issues.Status = '" & Me.Status & "'" & _
" OR " & _
<next condition> & _
")" 'put closing paren
End If

By the way your NZ() function is wrong since NZ converts null to a zero, you
need to test for zero

-Dorian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top