Results 1 to 2 of 2
  1. #1
    Petr Danes is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    18

    Repeated rebuild of right-click menu throws error

    I have an Access application that was originally built in Access 2000. Several textboxes and comboboxes use custom right-click menus to call filter routines. The RC menus are built in code, and some are quite extensive - hundreds of items, nested up to four levels deep.When data in a field changes, I need to rebuild the menu for that field, because the menus filter on the database's actual contents.

    In 2000, it all worked well, but in newer versions, repeated rebuilds throw an error.

    The relevant part of the code is here:





    Code:
    Dim rst0 As DAO.Recordset, rst1 As DAO.Recordset, rst2 As DAO.Recordset, rst3 As DAO.Recordset, qdf0 As DAO.QueryDef, qdf1 As DAO.QueryDef, qdf2 As DAO.QueryDef, AEp As CommandBarPopup, AEp1 As CommandBarPopup, AEp2 As CommandBarPopup, aec As CommandBarButton
        With Application.CommandBars("RCDatum")
            Do Until .Controls.count = 0
                If .Controls.count Then .Controls(1).Delete
            Loop
            Set rst0 = CurrentDb.QueryDefs("RCDatumDekady").OpenRecordset(acReadOnly)
            Set qdf0 = CurrentDb.QueryDefs("RCDatumRok")
            Set qdf1 = CurrentDb.QueryDefs("RCDatumRokMesic")
            Set qdf2 = CurrentDb.QueryDefs("RCDatumRokMesicDen")
            Do
                qdf0.Parameters("LoRok") = rst0.Fields("Dekada")
                qdf0.Parameters("HiRok") = rst0.Fields("Dekada") + 9
                Set rst1 = qdf0.OpenRecordset(acReadOnly)
                Set AEp = .Controls.Add(msoControlPopup)

    The last line is where it bombs with the error "Unable to add control", but not always. It runs several times, but after about four or five rebuilds, it suddenly starts throwing an error on that line. Shutting it down, doing a C & R and retrying makes it work again, and again several times okay, then starts bombing.

    I sort of suspect I'm abusing the RC system, that it was intended for a few items, more or less permanantly left in place, not such intensive build/rebuild activity with so many items, but I've not found any documentation on the subject, or anyone who claims to have experience with it.

    Anybody have any ideas?

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Right click menu with arrow
    By loy in forum Programming
    Replies: 9
    Last Post: 05-15-2017, 12:51 PM
  2. Replies: 7
    Last Post: 05-10-2017, 11:03 PM
  3. My code throws error 424. How do i work around this?
    By ThornofSouls in forum Programming
    Replies: 2
    Last Post: 09-11-2015, 06:30 AM
  4. right click context menu
    By rpeare in forum Programming
    Replies: 8
    Last Post: 10-27-2014, 11:16 AM
  5. Replies: 6
    Last Post: 01-29-2014, 08:03 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums