No Records Found

  • Thread starter Thread starter Steve7
  • Start date Start date
S

Steve7

Guest
I am new to Access and VB and am trying to do a partial text search using a combo box and a text box. This is working OK but i cann't seem to get a Message NO RECORDS FOUND when there is no match it just brings up a blank form. Have tried to do the things that have already been suggested to other users but I cannt seem to get them to work.

Any help would be appreciated.

This is the code that I am using for the search.

Private Sub btnSearch_Click()
Dim strSQL As String
Dim strCombo As String
Dim strText As String

Me.cmbSource.SetFocus
strCombo = Me.cmbSource.Value

Me.txtSearch.SetFocus
strText = Me.txtSearch.Text

strSQL = "[" & strCombo & "] like ""*" & strText & "*"""

DoCmd.OpenForm "frmEquipmentSearch", acNormal, , strSQL

End Sub
 
Try something like this in the Form_Open event of the form you are trying to open:

Dim rec As Recordset
Set rec = Me.RecordsetClone
If rec.BOF And rec.EOF Then
MsgBox "No Records Found"
Cancel = True
End If

Simon

[This message has been edited by SimonC (edited 03-19-2002).]
 
Thanks I'll give it a go
 

Users who are viewing this thread

Back
Top Bottom