VBA example - Microsoft Access: Recordset method to find record

Recordset: find record

In this example, you will learn Recordset Method to find record in a table. When the record is found, that record will be selected in a list box. The example illustrates a Search form that has a text box(Search), a list box(lstData), a command buttons(Search). See the figure below:

 VBA example - Microsoft Access VBA find record form  


Gandhi comment


Error Option Compare Database

How to solve it?

Nik comment


Thanks for you advise, I created the table with sample data per the example and then tried the form.

Dara comment


You need to create a table called TblProduct that contains the following fields: ProductID, ProductName, Quantity, and UnitPrice with some sample data.

Nik, email:nkarpak@gmail.com comment

 Nik, email:nkarpak@gmail.com

I tried the above form but it didn't work. When I opened the form it got the run time error '424': object required and highlighted following code:
lstData.RowSourceType = "Table/Query"

I'm using Access 2007 and just started VBA. I appreciate if you can help me to fix this error.


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.