Form Search - Confirmation dialogue help

T

TriX

Hello all.
I have a form with a "order number" field which i'm basing my searches on. I
successfully created a pop-up form that searches for a specified order number
and pulls the corresponding record (works alot like built in find feature).

The problem i am having, is that if the user searches for a order number that
doesn't exist, there is absolutly no feedback. When something isn't found
after they click search, nothing happens or changes. I was wondering if
someone could help me add a dialogue box promting the user a record can't be
found if its not there. Thanks so much.

Code (as found on the search form's, search button (onClick event):

Option Compare Database
Option Explicit

Dim mstrFormToSearch As String

Private Sub cmdFind_Click()

Static strLastFind As String
Dim ctlFocus As Access.Control
Dim strTemp As String
Dim I As Integer

If IsNull(Me.txtFindWhat) Then Exit Sub

With Forms(mstrFormToSearch)

.SetFocus

Set ctlFocus = .ActiveControl

On Error Resume Next
strTemp = ctlFocus.ControlSource
If Err.Number <> 0 Then
For I = 0 To .Controls.Count - 1
Set ctlFocus = .Controls(I)
If ctlFocus.Enabled = True Then
Err.Clear
strTemp = ctlFocus.ControlSource
If Err.Number = 0 Then
Exit For
End If
End If
Next I
End If
ctlFocus.SetFocus
On Error GoTo 0

End With

If Me.txtFindWhat = strLastFind Then
DoCmd.FindNext
Else

DoCmd.FindRecord _
Me.txtFindWhat.Value, _
acAnywhere, _
False, _
acSearchAll, _
False, _
acAll, _
True

strLastFind = Me.txtFindWhat

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