PDA

Click to See Complete Forum and Search --> : database can move first for the second times??


hcleo
Mar 15th, 2000, 02:16 PM
sorry about the topic it should be "can't " not "can" :þ
I was using the DAO 3.6 database, to begin a search i move my recordset to the first one using the command data1.recordset.movefirst, it's work for the first time. but the when the command is use again for the second time it return and error, why??? How can i solve this problem?

JohnAtWork
Mar 15th, 2000, 08:33 PM
Where you want the MoveFirst Method do this:

If rst.BOF = False then MoveFirst

hcleo
Mar 16th, 2000, 08:59 AM
yeah, i have use the the If rst.BOF = False then MoveFirst
method before in this way: but it still giving the same result - give the error message.

Clunietp
Mar 16th, 2000, 09:53 AM
This code works fine with DAO 3.6 & Access 2000 db:


Dim db As Database
Dim rs As Recordset

Set db = DBEngine.OpenDatabase("Nwind2k.mdb")

Set rs = db.OpenRecordset("Select * from Customers")

Debug.Print rs.Fields(0).Value
rs.MoveFirst
rs.MoveNext
rs.MoveNext

Debug.Print rs.Fields(0).Value
rs.MoveFirst
rs.MoveNext
rs.MovePrevious
Debug.Print rs.Fields(0).Value

rs.MoveFirst
rs.MoveFirst
Debug.Print rs.Fields(0).Value


What does your code look like?

hcleo
Mar 16th, 2000, 11:56 AM
First i put some data from the db to a combo box(not link to the db), after that the user can key in or click the combobox list to enter the choice. so the rs have move first twice, first time so get the data to put to the combo box second time is when the user choice the input. I'm was using the code almost same like john, just i'm using
"If Not rst.BOF Then rst.movefirst".

Michael
Mar 16th, 2000, 03:27 PM
What sort of recordset do you have. Is it forward-only?

hcleo
Mar 21st, 2000, 02:21 PM
Sorry for my late reply Michael, i'm not sure about the forward-only thing, but i have find out that this problem just occur in the current form, so may be there is some coding problem some way in my form thats make this happen, i'm still checking the source code. Any suggestion?