Instant Search Box In Access Form (Search Function in Navigation Bar) (1 Viewer)

vdanelia

Registered User.
Local time
Yesterday, 17:51
Joined
Jan 29, 2011
Messages
215
As Usual, When creating the form with Options and values on it (Combo-Boxes, Text-Boxes Based on a table)
has it's Navigation bar with Nav Buttons and "Search" function... I disabled Navigation Buttons, because i did myself with my design and customization (Working Perfectly - No problems), but I need that search function which was gone with navigation buttons..
How to create the same search on my own with text-box or something else (I call it instant search) Because it's searching very smartly.... and is very "Must Have" Option..


I'm Using The Code: It is not working as instant but very handy Search.....



Put a textbox in the form header. Name it txtSearch. Add a button named cmdSearch. Select the button in design view and press F7 to take you to the button's click event.
Change "CompanyName" to whatever your field name is. As long as it is a text field it should work.
Put this code in the Sub

Private Sub cmdSearch_Click()
Dim bkmk As Variant
Dim strField As String
Me.RecordsetClone.MoveFirst
'Find the first record that matches what
'is in the search text box.
Me.RecordsetClone.FindFirst "CompanyName Like " _
& Chr(34) & Me.txtSearch & "*" & Chr(34)

If Me.RecordsetClone.NoMatch Then
MsgBox "No Match"
Else
bkmk = Me.RecordsetClone.Bookmark
Me.Recordset.Bookmark = bkmk
End If
End Sub


how to add many fields (for example if i have 10 fields: field1, field2, field3, field4 etc) that the code could search in all fields not only specified..

Thank You Very Much
 

vdanelia

Registered User.
Local time
Yesterday, 17:51
Joined
Jan 29, 2011
Messages
215
Hi John! Greatest Thanks...
This is the Search I needed..... (It is a real Smart and Instant Search) Very Good Sample
Best Regards
 

gurmet

New member
Local time
Yesterday, 17:51
Joined
Aug 22, 2011
Messages
1
Hi

Sorry I have been following on this thread, but I m not able to type search criteria.
I have "Enter Surname:" ___________ {with a box that allows to input the surname that want to search}.

By the way I'm using MS Access 2007.

Please help.
 

Me!Fiesty

New member
Local time
Yesterday, 17:51
Joined
Mar 2, 2012
Messages
7
I've just used this code in form that has totals query as the underlying recordsource. It works beautifully so far. Instead of displaying a msgbox no match would like to open a form that I've already created that would give options to add the data. And if they decide no to clear the search box and set focus back to it. Any help would be appreciated for a total noob. Thanks.
 

spideynok

New member
Local time
Today, 08:51
Joined
Mar 23, 2012
Messages
7
Hi sir John! I have a question. what if I want to search multiple record like. I want to search Aglianico and Cabernets at the same time? Like I will put on the textbox is [Aglia, Caber] and it will show me Aglianico and Cabernets record?

I really did not enter the exact value, because I had a multiple search that can be separated by comma, but I need to enter the exact value, that's why I'm asking if how would you do to make that happen? Multiple Record search just using keyword.

BTW. Nice Multiple Search Sir John!
 

John Big Booty

AWF VIP
Local time
Today, 10:51
Joined
Aug 29, 2005
Messages
8,263
Hi sir John! I have a question. what if I want to search multiple record like. I want to search Aglianico and Cabernets at the same time? Like I will put on the textbox is [Aglia, Caber] and it will show me Aglianico and Cabernets record?

I really did not enter the exact value, because I had a multiple search that can be separated by comma, but I need to enter the exact value, that's why I'm asking if how would you do to make that happen? Multiple Record search just using keyword.

BTW. Nice Multiple Search Sir John!

You would need to implement a second search text box.
 

spideynok

New member
Local time
Today, 08:51
Joined
Mar 23, 2012
Messages
7
but my client need one textbox sir for them not to be confuse?
 

John Big Booty

AWF VIP
Local time
Today, 10:51
Joined
Aug 29, 2005
Messages
8,263
but my client need one textbox sir for them not to be confuse?

It can't easily be done with one text box, and I have no intention of even trying to get that to work.

So your client will either have to live with only searching on one string at a time, you will need to figure out how to split two strings in the text box so you can independently search on them (if you get that working please post back with your working sample) or your client has two search boxes.
 

Kit

New member
Local time
Today, 01:51
Joined
Mar 26, 2012
Messages
4
Hi,

sorry to butt in on this but would you know why my search has stopped working on the attached?

The radio buttons work though :)

Any reason why? Spent all weekend on it and cant work it out :(

Kit
 

Attachments

  • Dynamic Multi Search v2.zip
    128.6 KB · Views: 2,830

John Big Booty

AWF VIP
Local time
Today, 10:51
Joined
Aug 29, 2005
Messages
8,263
The reason is that you have no Query called QRY_SearchAll in your DB. If your Rename Query1 to QRY_SearchAll it should work again.
 

Kit

New member
Local time
Today, 01:51
Joined
Mar 26, 2012
Messages
4
Thanks John. It has got the radio buttons working but not the instant search?
 

John Big Booty

AWF VIP
Local time
Today, 10:51
Joined
Aug 29, 2005
Messages
8,263
The problem was in the Query you had too many criteria for the Frame, which meant that your query was really only functioning when you made a selection from the frame.

I've removed one of the frame criteria and your form now works.
 

Attachments

  • Dynamic Multi Search v2.zip
    140.9 KB · Views: 2,733

Kit

New member
Local time
Today, 01:51
Joined
Mar 26, 2012
Messages
4
Lol that small bit of code was stopping it. Bit more perseverance and I might have got it :)

Thank you John working great.

Time for the next phase....

 

spideynok

New member
Local time
Today, 08:51
Joined
Mar 23, 2012
Messages
7
Hi John! I found this database use to search using comma, referring on one column and it can search a keyword and can be separated by comma.

but my problem here is that I'm using a Form and Subform type.. can you help me to arrange this for my file? please? many thanks.

if my database is needed. I'm willing to upload it here :)
 

Attachments

  • universalsearch97.zip
    17.7 KB · Views: 525

John Big Booty

AWF VIP
Local time
Today, 10:51
Joined
Aug 29, 2005
Messages
8,263
Sorry that's not my code, you will need to contact the author of the DB.
 

spideynok

New member
Local time
Today, 08:51
Joined
Mar 23, 2012
Messages
7
uhmm Hi again John! uhmm I would like to give you my database and tell me how to do search by keyword multiple separated by comma? please :(
 

John Big Booty

AWF VIP
Local time
Today, 10:51
Joined
Aug 29, 2005
Messages
8,263
From up there ^^
It can't easily be done with one text box, and I have no intention of even trying to get that to work.

So your client will either have to live with only searching on one string at a time, you will need to figure out how to split two strings in the text box so you can independently search on them (if you get that working please post back with your working sample) or your client has two search boxes.
 

Users who are viewing this thread

Top Bottom