search bar for form (1 Viewer)

smartslingaro

Registered User.
Local time
Today, 05:05
Joined
Aug 23, 2019
Messages
17
what is the easiest way to have a search bar on a form that brings up the record in that form.
 

T. McConnell

Registered User.
Local time
Today, 08:05
Joined
Jun 21, 2019
Messages
63
Just putting my example that works for me in case it helps any. If it seems off to any of you experts please let me know :) I only want to help and hopefully get better as I go as well.

Smartslingaro,
Here is what I have used for a search box on a form. I have an unbound txtbox on my form called txtSearch. The I have a button with the below code attached to the OnClick event.
Code:
If (txtSearch & vbNullString) = vbNullString Then Exit Sub
    Dim rs As DAO.Recordset
    Set rs = Me.RecordsetClone
    rs.FindFirst "[JobID]=" & txtSearch 'JobID would be the field you are searching against i.e. employeeID etc..
    If rs.NoMatch Then
    MsgBox "Sorry, no such record '" & txtSearch & "' was found.", vbOKOnly, "No Record Found"

    Else
        Me.Recordset.Bookmark = rs.Bookmark
    End If
    rs.Close
    txtSearch = Null

Hope someone can find this useful maybe..
 

Users who are viewing this thread

Top Bottom