I have an application that’s worked well for over 8 years. In the last week, the forms’ performace have slowed down to the point of unusability on my main computer (Vista Home Premium). The behaviour was not present on my secondary machine (WinXP Pro). The mouse cursor would freeze, “Calculating…” would display in the status bar for 10-15 seconds when moving between records, windows would resist being moved, etc. Slow behaviour was even present when working with the actual (linked) tables. The frontend and backend are both on the local drive on this development computer. No other databases (including the backend) were affected.
The frontend and backend are A2000 format, running in A2003. The application had been converted from A97.
Finally traced it down to a section of code that constructed a menu using the Office 11 component. When I comment-out the call to BuildMenu, it worked properly. That’s the workaround I’ve used — just avoid calling the BuildMenu procedure when running on this computer. I haven’t changed the code in this section of the application in years, and I am fairly certain that nothing else I did would cause this behaviour. Any idea what is causing it?
Private Sub buildMenu()
Dim ToolsIndex As Integer
Dim NewMenu As Variant
‘To remove
On Error Resume Next
Application.CommandBars(“Menu Bar”).Controls(“LODM”).Delete
ToolsIndex = Application.CommandBars(“Menu Bar”).Controls(“Tools”).Index
Set NewMenu = Application.CommandBars(“Menu Bar”).Controls.Add _
(Type:=msoControlPopup, Before:=ToolsIndex, temporary:=True)
NewMenu.Caption = “&LODM”
AddMenuItem NewMenu, “Customers”, False, “=Openform(‘aFrmCustomer’)”
AddMenuItem NewMenu, “Tanks”, False, “=Openform(‘aFrmTankDetails’)”
AddMenuItem NewMenu, “Estimate”, False, “=Openform(‘frmEstimateFutureInventories’)”
AddMenuItem NewMenu, “Trip”, False, “=Openform(‘frmTripSummary’)”
AddMenuItem NewMenu, “Tank Analysis”, True, “=Openform(‘ufrmSelectTanksToAnalyzeConsumption’)”
AddMenuItem NewMenu, “Delivery Analysis”, False, “=Openform(‘frmDeliveryAnalysis’)”
AddMenuItem NewMenu, “Inventory Update”, False, “=Openform(‘uFrmUpdateInventory’)”
AddMenuItem NewMenu, “Main menu”, True, “=Openform(‘@frmMain’)”
AddMenuItem NewMenu, “About”, False, “=Openform(‘uSysAbout’)”
End Sub
Public Sub AddMenuItem(vMenu As Variant, _
psCaption As String, pbBegin As Boolean, psAction As String)
Dim ctl As CommandBarControl
Set ctl = vMenu.Controls.Add(Type:=msoControlButton, temporary:=True)
With ctl
.BeginGroup = pbBegin
.Caption = psCaption
.FaceId = 0
.OnAction = psAction
.Visible = True
End With
End Sub