Code help please

alguzman

Registered User.
Local time
Today, 01:01
Joined
Aug 2, 2001
Messages
63
I want to be able to have a msgbox pop up if no records were found. I tried a couple of things but they did not work. Here is my orignal code without my added mess. Can someone give me a hand. Thanks.



Private Sub btnFindFirst7_Click()

Dim MySrchString As String

If IsNull(Me.txtSearch7) Then
MsgBox "Please enter a search text", vbExclamation, "No Search Entered"
Exit Sub
Else
MySrchString = Me.txtSearch7
Me.Fax.SetFocus
DoCmd.FindRecord MySrchString, acAnywhere, , acSearchAll, , acCurrent
Me.btnFindNext7.Visible = True
End If
End Sub
 
Try this in your code:


Code:
Private Sub btnFindFirst7_Click()
Dim MySrchString As String
Dim ctrCurrent As Control

If IsNull(Me.txtSearch7) Then
    MsgBox "Please enter a search text", vbExclamation, "No Search Entered"
    Exit Sub
Else
    MySrchString = Me.txtSearch7
    Me.Fax.SetFocus
    Set ctrCurrent = Screen.ActiveControl
    DoCmd.FindRecord MySrchString, acAnywhere, , acSearchAll, , acCurrent
    If InStr(1, ctrCurrent, MySrchString) = 0 Then
        MsgBox "No Records Found"
    End If
    Me.btnFindNext7.Visible = True
End If

End Sub
 
Thanks. that bit of code worked fine. I will use it.

Thanks again.:D
 

Users who are viewing this thread

Back
Top Bottom