CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Location
    Québec (Canada)
    Posts
    210

    Data.Recordset.Edit for Table ( .dbf)

    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


  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Data.Recordset.Edit for Table ( .dbf)

    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
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured