Hi,

In vb i use Data Form Wizard and connect access database and create a form which automatically creates update,add,delete,etc buttons.

Now what i need is when i open the form and enter (say some student id)in a field then the next field is the student name which should be automatically filled based on the Id.

Can somebody help me on this please.

Krs

Am using data form wizard to create forms automatically by Vb with code.

What i need is to retrieve the value of the textbox based on the previous textbox value.(ie)if i enter student id then the next textbox should automatically retrieve the name from access database and display it rather than typing the name manually by user.

I am assuming that you are using a data control with the form? If so then you would search as follow -

datBooks.Recordset.FindFirst "'MySearchCriteria'" 'Notice the hyphens ', this for finding the first record if there might be more than one, or -
datMembers.Recordset.FindNext "'MySearchCriteria'" to go to the next record

Read more on this on -

http://www.vb6.us/tutorials/database-access-vb6-data-control-tutorial

Am using data form wizard to create forms automatically by Vb with code.

What i need is to retrieve the value of the textbox based on the previous textbox value.(ie)if i enter student id then the next textbox should automatically retrieve the name from access database and display it rather than typing the name manually by user.

Set your textbox datasource to your data control. Set the datafield property to your student name or surname or whatever field you have in the table. In your text search box's Lost Focus event you will add the code I supplied above for search. Once a record is found, the textboxes set to your data control will be automatically filled with the respective data.

This article has been dead for over six months. Start a new discussion instead.