Message required

M

Mazza

I have a continuous form which has a search function. What I would like is a
message to appear when you search and no records are found telling the user
that their search returned nothing instead of a blank form.
Any help would be greatly appreciated
Mazza
 
A

Al Campagna

Mazza,
Consider a Find that won't allow the user to even look for a value that does not exist.
Let's say you'd like to locate an OrderNo. If you provide the user with a combo box
populated with only legitimate "existing" OrderNos, and set the LimitToList to YES, then
the user can never search for an OrderNo that does not exist.
 
A

Access101

Let me know if this helps. This is kind of cheezy, but it seems to work:

Me.SearchField.SetFocus
DoCmd.FindRecord SearchVal

If SearchVal <> Me.ActiveControl Then
MsgBox "record not found"
End If
 
A

Access101

If you are searching for values like OrderNo, like Al suggests, then
something like this should help.

Private Sub cmbFindContact_AfterUpdate()

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[AppearanceID] = " & Str(Nz(Me![cmbFindContact], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub

Otherwise, if you're searching for stray words in MEMO fields, you might try
my workaround, if you don't find anything else.
 
Top