Results 1 to 8 of 8

Thread: [RESOLVED] MSFlexgrid - Refreshing data on grid.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    19

    Resolved [RESOLVED] MSFlexgrid - Refreshing data on grid.

    I am new to VB6.

    I have a MsFlexgrid that loads data from an Access table. I have an Edit button on the same form as the MSFlexgrid control. This Edit button calls a 2nd "Edit" form.

    I can Edit a record/row just fine in the Edit Form. It updates the Access table record, but does not refresh on the MSFlexgrid after exiting the Edit form.

    The row contains the original value. If I edit it a second time, the Edit information box has the changed data.

    In the "main form" in the Form_Load() I have:

    Call UpdateGrid
    ' This upates the MSFlexgrid control from a recordset.

    When I exit the Edit Form, I update the Access table and from
    here Call "Main Form".UpdateGrid (Same sub)

    What trick am I missing with the MSFlexgrid control?

    Here is some of the UpdateGrid code if that matters:
    Code:
    Public Sub UpdateGrid()
        Dim strSql            As String
        Dim intRecordCount    As Integer
        Dim intTheRow         As Integer
        
        strSql = "Select name, address from names'
        Set rs = New ADODB.Recordset
        With rs
            .ActiveConnection = adoSupplier
            .CursorType = adOpenKeyset
            .CursorLocation = adUseClient
            .LockType = adLockOptimistic
            .Source = strSql
        End With
        rs.Open
            
        intTheRow = 0
        With fgrdNames
            .TextMatrix(0, 0) = "Names"
            .TextMatrix(0, 1) = "Address"
    
            Do Until rs.EOF
                intTheRow = intTheRow + 1
               .TextMatrix(intTheRow, 0) = rstSupplier.Fields("name").Value
               .TextMatrix(intTheRow, 1) = rstSupplier.Fields("address").Value
               rs..MoveNext
            Loop
        End With

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: MSFlexgrid - Refreshing data on grid.

    When you exit your Edit form and call UpdateGrid, did you check what's happening inside the loop? Did you add a brakpoint to see if it was looping something?
    Also that UpdateGrid is present just in the main form, isn't it?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    19

    Re: MSFlexgrid - Refreshing data on grid.

    Yes I have checked.

    It definitely gets called and loops through the recordset a 2nd time (when existing the edit form).

    Any ideas on why it is not refreshed on the screen in the MSFlexgid?

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: MSFlexgrid - Refreshing data on grid.

    Do you have two periods here or is that a mistake?
    Code:
    rs..MoveNext
    There should only be one.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    19

    Re: MSFlexgrid - Refreshing data on grid.

    There is only one in the actual code. My mistake. I hit key again after I pasted the code.

  6. #6
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: MSFlexgrid - Refreshing data on grid.

    Is the connection adoSupplier the same connection used by the Edit form? Are you using the Jet Provider? Jet caches writes to the database. Only recordsets opened on the same connection will see the updates immediately. If you are using a different connection you will need to wait a few seconds before retrieving the data.

    If adoSupplier is the same connection used by both, try this change

    VB Code:
    1. With rs
    2.         [B]Set [/B] .ActiveConnection = adoSupplier
    3.         .CursorType = adOpenKeyset

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    19

    Re: MSFlexgrid - Refreshing data on grid.

    brucevde,

    You are the man.

    Thank you. I was using a different Connection and it was "caching". I could not figure out why this was working in "debug" mode, but not real time.

    I passed the same "adoConnection" to the Edit form and it works now.

    I have been beating my head against a wall for over 3 hours trying different things.

    Thanks again. I can only hope that the favor will be returned to you 10 fold.

    Scott

    P.S. I consider this one resolved, but do not know how to "tag/mark" it as such.

  8. #8
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: MSFlexgrid - Refreshing data on grid.

    Quote Originally Posted by ScottMatthews
    brucevde,

    You are the man.

    Thank you. I was using a different Connection and it was "caching". I could not figure out why this was working in "debug" mode, but not real time.

    I passed the same "adoConnection" to the Edit form and it works now.

    I have been beating my head against a wall for over 3 hours trying different things.

    Thanks again. I can only hope that the favor will be returned to you 10 fold.

    Scott

    P.S. I consider this one resolved, but do not know how to "tag/mark" it as such.
    Pull down the thread tools Menu and click "mark thread Resolved".
    Also, when you get to 20 posts, you will have 1 reputation power, then you could get back to this post and rate Bruce's post, it's a nice way to thank the person who helped you.

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