Access VBA

I am trying to create a search form. I would like the search form to search the DataEntry table. If the data exist and disposal is checked, then the search form displays the data. The data exists and the disposal check is unchecked then give an error message. If the data does nto exist at all give an error message.

Here is the code I have so far:

Option Compare Database
Private Sub cmdSearch_Click()
Dim strSampleNumber 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 a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtSearch].SetFocus

Exit Sub
End If
'-------------------

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

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

sampleno.SetFocus
strSampleNumber = sampleno.Text
txtSearch.SetFocus
strSearch = txtSearch.Text

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

If strSampleNumber = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
txtSearch.SetFocus
txtSearch = ""

'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Sample ID " & strSearch & " has not been disposed.", _
, "Invalid Sample ID!"
txtSearch.SetFocus
txtSearch = ""
End If
End Sub
[1847 byte] By [computerman29651] at [2007-11-20 10:47:57]