Search Button Code... (1 Viewer)

xyba

Registered User.
Local time
Today, 14:36
Joined
Jan 28, 2016
Messages
189
I know this has been answered in various ways over the years but I can't find a simple answer to simple coding. Most answers are for multiple fields or refer to using the wizard (which doesn't seem to work for me as it doesn't ask for any fields or search box to be able to set it up properly).

I did have my button working but, Access threw a fit yesterday and crashed losing ALL my VBA code, but leaving the db components intact thankfully.

What I want is to enter a value in SearchBox to search field RecordNo when I press SearchBtn.

Any help appreciated.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:36
Joined
Jul 9, 2003
Messages
16,244
What I want is to enter a value in SearchBox to search field RecordNo when I press SearchBtn.

And the results of the search? Where do you see them?



Sent from my Pixel 3a using Tapatalk
 

xyba

Registered User.
Local time
Today, 14:36
Joined
Jan 28, 2016
Messages
189
In the bound form in which the search box and button are located.

The form is bound to Record (the name of the table)
 

xyba

Registered User.
Local time
Today, 14:36
Joined
Jan 28, 2016
Messages
189
I managed to get it to work. For anyone wondering, this is the code I used:

Code:
Private Sub SearchBtn_Click()
If IsNull(SearchBox) = False Then
Me.Recordset.FindFirst "[RecordNo]=" & SearchBox

      Me!SearchBox = Null

      If Me.Recordset.NoMatch Then

         MsgBox "No Record Found", vbOKOnly + vbInformation, "Sorry"

            Me!SearchBox = Null

      End If

   End If

End Sub
 

Users who are viewing this thread

Top Bottom