Private Sub cmdSearch_Click()
Dim varWhere As Variant
' Initialize to Null
varWhere = Null
' Do Issue Subject next
If Not IsNothing(Me.txtIssueSubject) Then
' .. build the predicate
' Note: taking advantage of Null propogation
' so we don't have to test for any previous predicate
varWhere = (varWhere + " AND ") & "([IssueSubject] LIKE '" & Me.txtIssueSubject & "*')"
End If
' Do Issue Description next
If Not IsNothing(Me.txtIssueDesc) Then
' .. build the predicate
varWhere = (varWhere + " AND ") & "([IssueDescription] LIKE '" & Me.txtIssueDesc & "*')"
End If
If Not IsNothing(Me.cmbIssuer) Then
' .. build the predicate
varWhere = "(UserID.Value = " & Me.cmbIssuer & ")"
End If
' Check to see that we built a filter
If IsNothing(varWhere) Then
MsgBox "You must enter at least one search criteria.", vbInformation, gstrAppTitle
Exit Sub
End If
' See if any rows with a quick DLookup
If IsNothing(DLookup("ServiceRequestID", "tblSystemServiceRequest", varWhere)) Then
MsgBox "No Service Request meet your criteria.", vbInformation, gstrAppTitle
Exit Sub
End If
' Open Companies filtered
' Note: if form already open, this just applies the filter
DoCmd.OpenForm "frmSystem_ServiecRequest", WhereCondition:=varWhere
' Done
DoCmd.Close acForm, Me.Name
End Sub
Posted by: dbalorenzini@yahoo.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (1) |
Tidak ada komentar:
Posting Komentar