Error with Access Menus

A

Ayaz Hoda

I am trying to find a way to load customize menu, as defined in Ribbon UI
Customization in Access 2007.

An Autoexec macro that calls that procedure by using Runcode action

Function LoadRibbons()
Dim i As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = Application.CurrentDb

uid = CUser()

If uid = 66 Then
For i = 0 To (db.TableDefs.count - 1)
If (InStr(1, db.TableDefs(i).Name, "Ribbons")) Then

Set rs = CurrentDb.OpenRecordset(db.TableDefs(i).Name)
rs.MoveFirst
While Not rs.EOF
MsgBox "User ribbon"
Application.LoadCustomUI rs("RibbonName").Value,
rs("RibbonXml").Value ' Error on this line Runtime error 32609, Cannot load
customization 'test2' this customization was already loaded

Wend

rs.Close
Set rs = Nothing
End If
Next i

End If

db.Close
Set db = Nothing
End Function

Please any suggestion or advice

Thanks
 
B

Brendan Reynolds

While Not rs.EOF
MsgBox "User ribbon"
Application.LoadCustomUI rs("RibbonName").Value,
rs("RibbonXml").Value ' Error on this line Runtime error 32609, Cannot
load
customization 'test2' this customization was already loaded

Wend
<snip>

Aren't you missing an "rs.MoveNext" before the "Wend"? Without that, if the
recordset contains one or more records, the code will attempt to repeatedly
load the value from the first record, because rs.EOF will never be True.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top