Good day!

How to move to a specific record base on the current recordset of adodc control? I have this employee_(empID, empName, EmpSalRate).

I have load all employees data by using this code:

dim Sql as string
Sql="select * from tml_employee order by empName Asc"
AdoDc.ConnectionString=Conn
AdoDc.RecordSource=Sql
AdoDc.Refresh

Thus, I also have text boxes that has a recordsource of this AdoDC. Now I need to move to a record whos empName is equal to "Ana Josh" and EmpSalRate=15, 000.00.

Thank you for helping!

You need to change your SELECT statement to -

Sql="SELECT * FROM tml_employee WHERE empName LIKE '%" & TheEmpNameVAlueHere & "%' AND EmpSalRate ='" & TheRateValueHere & "' ORDER BY empName ASC"

thank you AndreRet!

Ive figure that out too. But I just want to move to a record currently in the adodc.. so if I have 50 employees returned by ADODC Control, I want to move to a record whos name is equal to "Ana Josh" and EmpSalRate=15, 000.00!..I dont want to create another query anyway!

Unfortunately you have to tell your data control where to go. The ONLY way to do this is to select a record and then move the control to that record if found... :)

The below sql statement will look for a record where the name AND the rate is = to what you need.

Sql="SELECT * FROM tml_employee WHERE empName ='" & TheEmpNameVAlueHere & "' AND EmpSalRate ='" & TheRateValueHere & "' ORDER BY empName ASC

AdoDc.ConnectionString=Conn
AdoDc.RecordSource=Sql

Text1.Text = AdOdc.Fields!empName

thank you AndreRet!

But if I click on the next record of the adodc control, I cannot move to the record after the "Ana Josh". Do I need to run the first query as like this:

Sql="select * from tml_employee order by empName Asc"
AdoDc.ConnectionString=Conn
AdoDc.RecordSource=Sql
AdoDc.Refresh anyway!

But I think I will loss the position of the next data.

I click on the next record

I cannot move to the record after the "Ana Josh"

That is because you have searched for a specific record. If you can not move to the next record, it means that there are no more records with the name "Ana Josh" and a Salary rate of "$15000" If you want to see any other records, you need to reload your data control with your code as above to start scrolling through all records.

Normaly the sql that I provided is used in a search button where a user can search for a specific criteria...

Thank you AndreRet!

Ive also figuring about

AdoDc.Recordset.find

It was only a pleasure :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.