Finding Matching Records in Data Access Pages - The code page and the code to search the EmployeeID
(Page 3 of 4 )
Now open up the Microsoft Script Editor as shown with all elements showing at the top of this picture. The "Document Outline" window shows all the objects on this DAP relating to the data-related objects as well as any control element you placed on the page (in this case, a textbox was placed).

Now scroll down until you come to the textbox whose ID is IdEmp as shown in the next picture.

Since this is a textbox, the onchange event is a natural event that is invoked when you type something into the textbox and step out of it. Double click the onchange event in the "Document Outline." This opens up a region in the Microsoft Script Editor and places a vbscript-related tag for that particular element as shown.

Now what is required is to code in such a way that the EmployeeID field in the recordset will be searched until the text typed in the box whose id is "IdEmp" is found. The following code does just that. The script is vbscript and it is written for the "onchange" event of the object whose Id is "IdEmp." The language syntax is Microsoft's, which can be recognized by the "document.all.item()" method and is IE specific. As mentioned previously, the data in the DAP is passed to the MSODSC's default recordset. This is all that is needed to find all the information for this EmployeeID.
Testing this code
Open the page in preview mode, which will require you to save it first. This page is already saved as "TestEmployees.htm." When this is opened the employee information for the employee whose IdEmp =1 will be showing, and the textbox will be empty. Type a number (there are only nine employees in this table) and step out of the box and you will see the record for the employee displayed as shown. The picture as shown is for the number 6 typed into the textbox.

Next: Using Combo boxes to find records >>
More Database Code Articles
More By Jayaram Krishnaswamy