Click to See Complete Forum and Search --> : Data.Recordset.Edit for Table ( .dbf)


regis
April 7th, 2000, 10:18 AM
I try to change a value to table dbf but the result is not good.

This is my code

Sub...
Data1.Recordset.MoveFirst

Do While Data1.Recordset.EOF = False
Data1.Recordset.Edit
Data1.Recordset("Dhp_20").Value = 50 Data1.Recordset.Update

Data1.Recordset.MoveNext

Loop
End sub...

And after that all my value in DHP_20 fields is equal Zero I don't understand the process.

And my field "DHP_20" it's a numeric field

Thanks
Redg

Johnny101
April 7th, 2000, 10:43 AM
I'm assuming your using DAO, since there is no Edit method in ADO. And you're using the DAO control.

My first question would be: If you are updating every row in the table to be one value, why not just issue an update statement instead of looping through the entire recordset?

Dim sql as string

sql = "UPDATE Table set "
sql = sql & "DHP_20 = 50 "
sql = sql & "WHERE 1=1" ' to get all the records

data1.database.execute sql





Be sure to do a refresh on the data1 control to make sure that your recordset has the most recent changes to the table.

Hope this helps/applies,

John

John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org