Context: I have an Access database application that was built in Access 2k. I have a custom ribbon built that I am playing around with, and I also have some user "security" in this app.
When a report opens, I want to check the username and switch to a different ribbon for specific users. I would think that this code would work:
The Code:
If GetUserName() = "admin" Then
Me.Report.RibbonName = "CustomPrintPreview"
Else
Me.Report.RibbonName = "MSToolbar1"
End If
The Problem:
This code seems to execute (and it's not doing On Error Resume Next
). However when the open event ends, the report opens with no data (when there should be data). If I remove this if block, it runs fine aside from setting the correct ribbon. I should mention that if I manually set the RibbonName property for the report, both ribbons work fine, so it is not a problem with the ribbons themselves.
I'm currently using access 2007, but this will be deployed for 2010 versions as well. Does anyone know what's going on here?