DAO recordset Movenext problem.

  • Thread starter Thread starter CK NG
  • Start date Start date
C

CK NG

Hi All,
I having a problem with using the recordset .MoveNext in access.
I have a form and using Combo Box to select and update data to certain
table. But i having a problem with using .MoveNext function. Eventhough i
able to detect the location where the data should be updated. When i use the
..MoveNext Function to access it, it always updated the wrong row of data.
Can anyone advice how to solve this problem? Thanks.

Here is the partial of my code:

'ProductValue is location for the data wish to update.

rsProducts.MoveFirst
For I = 1 To (ProductValue - 1)
rsProducts.MoveNext
'MsgBox "Product Value", vbOKOnly, I
Next I

rsProducts.Edit
rsProducts!StockUnit = UpdatedStockUnit

rsProducts.Update
rsProducts.Close

Your help is very appreciated. Thanks.

Best Regards,
C.K.
(e-mail address removed)
 
Unless you specifically coded a Query with a Sort on ProductValue that use
used to open the Recordset, or included an ORDER BY ProductValue in the SQL
used to open the Recordset, your assumption that the Recordset is in
ProductValue order may not be correct. And, if not, you have moved that far
in the Recordset, but updated whatever Record happened to come up. That is,
I see no explicit test for the correct Record.

By definition, the records in relational tables are _unordered_.

I suggest you make certain of the order, as described above, and then use a
..FindFirst to find the Record of interest, instead of stepping individually
through each Record that precedes it.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top