473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How Do I Create A Search Box?

23 New Member
Hi folks, looking for help on what I reckon should be easy, but can't seem to find an easy solution.

I've tried searching loads of different solutions, but none seem to be for what I'm trying to do, a simple search box.

Using Access 97, I've created a form - frmTests - which shows, in Form view as continous forms, all records from a table relating to items being tested.

In previous databases, I would have just placed a command button with simply...

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdGoFindText_Click()
  2.  
  3.     Screen.PreviousControl.SetFocus
  4.     DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
  5.  
  6. End Sub
  7.  
But with this database, I'm wanting to something very similar, except the search string input box already exists on the form, call it, for example, txtSearchString to save the user from scrolling down thousands of records. I type in a string to the text box, then click a "Go" button next to it, which will then carry out a sort of "Find Next" style function and highlight the text I'm looking for.

In my head, it seems a very simple task, which shouldn't have much code to it. I know I could just use the DoMenuItem feature instead, but it's not what the user wants.

Currently, my code looks like this, and appears to do nothing, no failure, no highlight..

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdGoFindText_Click()
  2.     If IsNull(Me.txtTextToFind) = True Then
  3.         MsgBox ("No search term entered!")
  4.         Me.txtTextToFind.SetFocus
  5.     Else
  6.         strWhere = Me.txtTextToFind
  7.         DoCmd.FindRecord strWhere, acEntire, True, acSearchAll, True, acAll, True
  8.     End If
  9.  
  10. End Sub
  11.  
Jul 26 '10 #1
2 2410
munkee
374 Contributor
d4zza just to clarify you are wanting them to be able to find the first instance then click again to find the next instance etc? or just filter the records based on the string (which you seem to be able to do anyway)
Jul 26 '10 #2
d4zza
23 New Member
@munkee
Hi, sorry for late reply, was trying various solutions.

Just wanted a simple search once function, no filter. Unbound text box, txtTextToFind, on the form is used to enter a string of text to find, then user clicks a "Go" command button, and the form will find and highlight the first instance, no find next required.

I did crack it this morning though. Based on the result with previous script, where nothing appeared to happen, I added in a field reference to focus on before searching. Code is now...

Expand|Select|Wrap|Line Numbers
  1. strWhere = Me.txtTextToFind
  2. Me.ReferenceNo.SetFocus
  3. DoCmd.FindRecord strWhere
  4.  
I'm only having to search the one field, ReferenceNo, and they all have unique entries.
Jul 27 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: VLAD | last post by:
I have a folder with a lot of .doc files in it. Is possible to create search function for aspx page that will search those documents for specific information and will display names of the files...
2
by: Scott | last post by:
I'm trying to use the HTMLHelp API calls in a VB.NET program because I want a little more functionality than is offered by the Help class in .NET. Everything works fine except for displaying the...
0
by: qonhfmwfyrqx | last post by:
Discover how to quickly and easily create search engine optimized affiliate web sites that can make you money, even without any HTML knowledge or search engine optimization skills. Create...
2
by: chobo | last post by:
I'm not sure where to post this question, so sorry if it's in the wrong place. I have a design related question relating to xml files stored in a mysql database. I was wondering how some of you guys...
0
by: zzapper | last post by:
Hi, I 've just learnt how to configure this go to http://uk2.php.net/ (or whatever) place your mouse cursor in the "Search For" Input Box Right Mouse Click and select "Create Search" Enter...
25
by: ali3n8 | last post by:
Hello I would like to create a search form for my database that searches by: First Last Contact Number Street City State Zip
5
by: LC2007 | last post by:
Hello, Can someone please help me on how to create Search Criteria form, i can't find exactly what i am looking for!!! i need a search button! but i can't find anything that can help me!
0
by: bhagawansharma | last post by:
hi friends i want to use a text box for the user to type letters and query the database to get some results and populate in a list box. Is it possible to do that. like .. using lest search...
3
by: mukeshrasm | last post by:
Hi I want to convert this URL http://www.example.com/whateversearch.php?action=search&kwd=whatever+keyword+76sdf789sfd6 To this http://www.example.com/whateversearch/whatever-keywords ...
1
by: Arthurr | last post by:
I have an Access database linked from SQL server and I need to create a search engine using VBA. I managed to create search engine for varchar items, but I cant make it to search numbers as well....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.