• Strange behaviour – menus (2003)

    Author
    Topic
    #450869

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1108709

      There’s nothing in the code that catches my eye.

      Do you have other Office applications (in Word, Excel, Access) that use code to create commandbars? If so, do they show the same behavior on the Vista machine? If not, could you create a small application to test this?

      • #1108728

        Good idea. I will add the code to another Access project and see what happens. Will let you know the outcome.

      • #1108754

        Found the answer…
        The frontend is A2000 format, running under A2003 on my computers. When used on a Vista machine, it exhibits the problem with sluggish performance. It works fine when used on XP. It also works fine when the frontend is converted to A2003 format.

        I converted the old application from A97 to A2000 because I thought it would be the best common format for all the machines used at the clients worksite. Time to re-evaluate that decision! My understanding is that the preferred format for backend is A2000 regardless of the frontend format

        (Aside: I enabled the menus and saw the sluggish performance. Then disabled the menu in code and closed the frontend manually WITHOUT using code to remove the menu. Re-opened the frontend (with the menu-code disabled). Performance was now at proper level — not sluggish. It appears to be the *creation* of the menu, not the *presence* of the menu that is causing the sluggish performance.)

    Viewing 0 reply threads
    Reply To: Strange behaviour – menus (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: