PDA

Click to See Complete Forum and Search --> : Find help in ADO


Long
Oct 11th, 1999, 10:14 AM
Hello
Now, I tried to make a new Application where in this program have a button such as :
First, Previous, Next, Last, Find.
table name : offmat
field : omat_code
omat_name
omat_unit

Dim myconn As New ADODB.Connection
Dim myrec As New ADODB.Recordset

In event Find Click, i put a statement :

myrec.open "select * from offmat where omat_code ='" & trim(txtfield.text) & "'",myconn, adOpenDynamic, adLockOptimistic, adCmdText
if (myrec.bof <> true) and (myrec.eof <> true then
call displayrecord
check = true
endif
myrec.close

if check = false then
msgbox "Data cann't be found"
endif

When I run the current the record is first record and I can move the record with press button first or previous or next or last.
Example now the current record is first record then i press find button( to find record seven) and i put data.
When it's find then the data to show, but when data show first or previous or next or last button not work.
I want when data to find is record of seven and when i press next button current record will move to record of eight or previous record
current record will move to record of six.
I have tried it with statement

myrec.open "offmat",myconn, adOpenDynamic, adLockOptimistic, adCmdText
myrec.movefirst
do while not myrec.eof
if trim(myrec!omat_code) = txtfield.text then
call displayrecord
check = true
exit do
endif
myrec.movenext
loop
myrec.close

if check = false then
msgbox "Data cann't be found"
endif

This code it's work like i want but if in my table have 1000 record it will be take a long time to find
So somebody can help me ?


Regard's


Long




[This message has been edited by Long (edited 10-12-1999).]

RajSatish
Oct 12th, 1999, 06:47 PM
Hi,
Can u tell me what's the code which u have put in other buttons.