Optional Search

H

Heather

Hello,

Right now my form has 1 search and it searches by Old report number. I would
like to add an additional search that would be an optional serach. The Old
Report Number is always required entry and New Report Number would be is
optional. What is happing is that the Old Report number is being split in to
two reports so I can Have 2 records.

Old New Report
RPT1098 RP2030
RPT1098 TP2030

Can anyone tell me how to add an the New Report number in my search?

This is my Current code
Private Sub cmdSearch_Click()
Dim strReportRef As String
Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.

If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter an Old Report value!", vbOKOnly, "Invalid
Report Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------

'Performs the search using value entered into txtSearch
'and evaluates this against values in strReportRef

DoCmd.ShowAllRecords
DoCmd.GoToControl ("RPT_OLD_ID")
DoCmd.FindRecord Me!txtSearch

RPT_OLD_ID.SetFocus
strReportRef = RPT_OLD_ID.Text
txtSearch.SetFocus
strSearch = txtSearch.Text

'If matching record found sets focus in strReportRef and shows msgbox
'and clears search control

If strReportRef = strSearch Then
MsgBox "Match Found For Report: " & strSearch, , "View Direct Report!"
RPT_OLD_ID.SetFocus
txtSearch = ""

'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For Report: " & strSearch & " - Please Try
Again.", _
, "Invalid Report Criteria!"
txtSearch.SetFocus
End If
End Sub
 

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