Results 1 to 4 of 4

Thread: Problem in recordset.move

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    17

    Problem in recordset.move

    hi,
    I am using recordset to connect to the MS access from vb6. I am using recordset.move to get the data, example show as below:

    Code:
    '*** saved to db
    rsDataTrend.AddNew
    :
    rsDataTrend.Update
    
    rsDataTrend.MoveLast
    lTotalRecords = rsDataTrend.RecordCount
    
    rsDataTrend.MoveFirst
    rsDataTrend.MoveLast
    EmptyRow = 0
    DoEvents
    
    '*** get the last 40 values
    If lTotalRecords >= 40 Then
        rsDataTrend.Move -40
        EmptyRow = 0
    Else
        rsDataTrend.MoveFirst
        EmptyRow = 40 - lTotalRecords
    End If
    
    DoEvents
    rsDataTrend.MoveLast
    rsDataTrend.Move -40
    
    '*** retrive value one by one from database by using for loop
    :
    If Not (rsDataTrend.BOF) Then
       .RowLabel = Format$((rsDataTrend("RTime")), "hh:mm:ss")
       '***some coding here
    endif
    Sometime the coding above is no problem.But its failed to retrive the latest data from database even the data have been store into database.

    Example, the total record is 400, when using the code to retrive the values, i will get the data start from 360 to 400. But sometime i will keep getting the same data(360 - 400) even the total record was changed to 450.

    Does anyone tell me the any possible could course this problem happened?

    Thanks in advance.

    regards
    cocoonwls

  2. #2
    Hyperactive Member
    Join Date
    May 2006
    Posts
    365

    Re: Problem in recordset.move

    Hello,

    Although you haven't posted the code to open the connection and then to fill the recordset I do believe that, based on assumptions, you are not emptying the recordset object at the correct time.

    I shall expand:
    The recordset object is a client side matrix containing rows of records that is stored in RAM. Updates not written back to the database will also be stored in RAM.
    If you were to delete the recordset object then rebuild the recordset object with the new data I believe you would have better results.

    Kind regards
    Steve

    PS
    I have an exam today so the chances of me posting back are very low.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    17

    Re: Problem in recordset.move

    Hi steven,
    Thanks for your reply. Do you mean delete the recordset before i get the latest data, like below(red colour font):

    Code:
    '*** saved to db
    rsDataTrend.Add
    :
    rsDataTrend.Update
    
    '***close rs ,delete and reset again the recordset***
    rsDataTrend.Close
    rsDataTrend.Delete
    Set rsDataTrend = dbMPP.OpenRecordset("Main", dbOpenTable)
    '***end***
    
    rsDataTrend.MoveLast
    lTotalRecords = rsDataTrend.RecordCount
    '***some coding here
    I will try it.Again, thank you


    regards
    lswang

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Problem in recordset.move

    You could also try a .Refresh

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