When opening my form for the first time and searching for a record, it displays the 'no record found' MsgBox as well as returning the actual record. The same code works fine in another database that I have created, so what am I doing wrong here?
Code:
Private Sub SearchButton_Click()
Dim rsTemp As Recordset
If IsNull(Me.SearchField) = False Then
Set rsTemp = Me.RecordsetClone
rsTemp.FindFirst "[TIDRef] = '" & Me.SearchField & "'"
If Not rsTemp.NoMatch Then
Me.Bookmark = rsTemp.Bookmark
Else
MsgBox "No record found", vbOKOnly + vbInformation, "Sorry"
End If
Me.SearchField.Value = Null
End If
If IsNull(Me.SearchField1) = False Then
Set rsTemp = Me.RecordsetClone
rsTemp.FindFirst "[CompassRef] = '" & Me.SearchField1 & "'"
If Not rsTemp.NoMatch Then
Me.Bookmark = rsTemp.Bookmark
Else
MsgBox "No record found", vbOKOnly + vbInformation, "Sorry"
End If
Me.SearchField1.Value = Null
End If
End Sub