Henrik
2015-06-23T10:45:01Z
I have a bound form in Access 2010 with a tab control. I've placed and successfully used two grids on two separate tabs.

When I placed a third grid on a new tab I couldn't see the rows I was filling the grid with.

It seems to have something to do with End/BeginUpdate. If I place a fresh grid on the tab and use AddRow without Begin/EndUpdate it works as intended. When I reload the rows with End/BeinUpdate called, the content turns invisible. I can see that the grid is being filled with data and I can copy cells and paste text in a text document. When I turn off Begin/EndUpdate in the update procedure it is still broken.

The other two grids in the form does not have this issue.

Any thoughts? Am I missing something simple?

I've simplified the code for testing purpose:

Dim g As iGrid
Dim l As Long

Set g = Me.gEntreprenad.Object

g.BeginUpdate
g.Clear

l = g.AddRow()
g.CellValue(l, 1) = "a1"
g.CellValue(l, 2) = "a2"

g.EndUpdate

Set g = Nothing

SOLVED:
It turns out I exited the update procedure in some cases without .EndUpdate. *slap self*
Dan
2015-06-23T16:18:49Z
Hi,

I've been caught out a few times with this. I now have a safety net subroutine I call that has something like this:


Sub iGridEndUpdate()
    
    Dim i as Integer
    
    For i = 1 to iGrid1.BeginUpdateCount
        iGrid1.EndUpdate
    Next
    
End Sub

Just change iGrid1 to whatever your grid object variable is, or you could have a parameter passed in so it could be used as a single cleanup for all grids on all forms if needed.

This way it doesn't matter how many nested BeginUpdate calls you might have (I've ended up with around 5 before due to looping through various nested routines that adjust part of the grid, but not more than that yet), just make sure you always call that sub before exiting and it'll ensure that all outstanding updates are completed.

Dan
ArtA
2016-07-26T15:43:11Z
Man, this helped me out today. I couldn't figure out for the life of me with the rows which were being added to the grid weren't displaying! The BeginUpdateCount property revealed the clue which I was able to use to refine my search through code for the spot where I was exiting a loop and bypassing an EndUpdate call. Thanks!