Enabling toolbaritems

I’ve got the code below to enable or disable toolbaritems when a database is opened/closed or a record in the database is selected/deselected. The code works fine except in one situation.

When I open a database and then add data everything is okay. However when I open the database in the background and then add data then the code doesn’t enable the toolbaritems. If I comment out a sheet that shows how many records were added to the database, then the code works as advertized.

Does anyone have an idea what might cause this? I’m rather late in the release cycle to try to change something how databases are opened because the sequence is rather complicated.

[code]Private Sub EnableDisableItemByName(theName as String, doEnable as Boolean)
dim theToolbar as NSToolbarMBS = self.Window.NSToolbarMBS
if theToolbar = nil then Return
dim theToolbarItems() as NSToolbarItemMBS = theToolbar.items

for each theItem as NSToolbarItemMBS in theToolbarItems
if theItem.label = theName then
theItem.Enabled = doEnable
theItem.autovalidates = false
end if
End Sub[/code]

Mac OS 10.9, Cocoa, Xojo 2013r4