You may have any number of reasons to find a particular recordset in a database. Sometimes finding what you want is easier said than done. This article walks you through the different search functions (also known as Find functions) and shows you when you should use them. This is the seventh part of a thirteen part series that focuses on database forms with HTML.
Using the Find Functions for HTML Database Forms (Page 1 of 4 )
FINDING A RECORD
Reasons for Finding a Record
You may have a recordset that is very long. Inspecting the records one row at a time can take a very long time. If you know one of the cell values of the record you are looking for, then a Find function can be written that will locate the record for you and then display it at the Input controls.
This part of the series deals with two such Find functions. The main Find function is called "Binary Search." The other function I use is called Ordinary Search. I will not explain the operation of the Binary Search function in this series. If you want to know how the function operates, consult the article I wrote for Dev Articles titled "Binary Searching." In this series I will only show you what goes into the function and what comes out of it.
The Search Functions
The starting search function is called the find() function. The ordinary search function is called the ordinarySearch() function. The binary search function is called the binarySearch() function.
The find() function does not search the recordset. It calls the ordinarySearch() or the binarySearch() function. The ordinarySearch() function is called when the recordset is not sorted, while the binarySearch() function is called when the recordset is sorted.
It is these two functions that do the search; I will explain more about this later. There is another function associated with the find() function; this is the getTwoWords() function; again, I will cover this in more detail this later.