S
Song Su
I have a search form. Users can type PONumber, LACCDTag, SerialNumber or
MonitorNumber in txtSearch textbox and select cboSearch to tell me which
field it is. Then I give RecordSource with strFilter.
How to test if search failed and give MsgBox?
Private Sub cboSearch_AfterUpdate()
Dim strFilter As String
Select Case cboSearch
Case "PO Number"
strFilter = " Where PO.PONumber = " & txtSearch
Case "LACCD Tag"
strFilter = " Where PODetail.LACCDTag = " & txtSearch
Case "Serial Number"
strFilter = " Where PODetail.SerialNumber = '" & txtSearch & "'"
Case "Monitor Number"
strFilter = " Where PODetail.MonitorNumber = '" & txtSearch &
"'"
End Select
Me.RecordSource = "SELECT PO.PONumber, PO.PODescription, PO.OrderDate,
PO.PayDate, PO.FundCenter, PO.OfficeID, PO.IT, PODetail.ItemDescription,
PODetail.LACCDTag, PODetail.SerialNumber, PODetail.MonitorNumber, PO.Comment
" & _
"FROM PO INNER JOIN PODetail ON PO.PONumber = PODetail.PONumber" &
strFilter
End Sub
MonitorNumber in txtSearch textbox and select cboSearch to tell me which
field it is. Then I give RecordSource with strFilter.
How to test if search failed and give MsgBox?
Private Sub cboSearch_AfterUpdate()
Dim strFilter As String
Select Case cboSearch
Case "PO Number"
strFilter = " Where PO.PONumber = " & txtSearch
Case "LACCD Tag"
strFilter = " Where PODetail.LACCDTag = " & txtSearch
Case "Serial Number"
strFilter = " Where PODetail.SerialNumber = '" & txtSearch & "'"
Case "Monitor Number"
strFilter = " Where PODetail.MonitorNumber = '" & txtSearch &
"'"
End Select
Me.RecordSource = "SELECT PO.PONumber, PO.PODescription, PO.OrderDate,
PO.PayDate, PO.FundCenter, PO.OfficeID, PO.IT, PODetail.ItemDescription,
PODetail.LACCDTag, PODetail.SerialNumber, PODetail.MonitorNumber, PO.Comment
" & _
"FROM PO INNER JOIN PODetail ON PO.PONumber = PODetail.PONumber" &
strFilter
End Sub