Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ChangeProperties Function

Status
Not open for further replies.

GTLoco99

Programmer
Sep 2, 2003
59
US
I have a ChangeProperties Function I use to turn off/on full menu access based off the CurrentUser(). I have this fire off in the AutoExec macro for the database. The problem I have is that it does not actually change the menus until the next time I log in. I want the change to take affect before the user gets to the swithboard. Am I doing something wrong? Below is my code

Code:
_________________________

Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

Change_Bye:
Exit Function

Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
________________________

Function ChangeStartUp()

Dim User As String

User = CurrentUser()

'If user is Admin, then allow full menus
If User = "Admin" Then
ChangeProperty "AllowFullMenus", dbBoolean, True
Else
ChangeProperty "AllowFullMenus", dbBoolean, False
End If

'Opens restricted swithboard for Edu, else opens normal
If User = "Edu" Then
DoCmd.OpenForm "Switchboard", acNormal, , "[ItemNumber] = 0 AND [SwitchboardID] = 6"
Else
DoCmd.OpenForm "Switchboard", acNormal, , "[ItemNumber] = 0 AND [SwitchboardID] = 1"
End If

End Function
_____________________________

Any help would be appreciated

Thanks
Glen
 
You can't change that property on the fly, what you need to do is create your own menu bar, and use

'If user is Admin, then allow full menus
If User = "Admin" Then
CommandBars("mnuAdmin").Enabled = True
Else
CommandBars("mnuAdmin").Enabled = False
End If

To create your own menu bar, right click on the menubar & choose customize. Create a new bar, turn it into a menu bar(by default it's a toolbar) then put on the options you want on it. you can copy the menus from the standard onto your new bar by holding down shift and dragging the menu from the standard to the new.

hth

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
Thats what I was afraid of. Was hoping to avoid creating new menus, but that looks like the route I need to go. Thanks for the help

Thanks
Glen
 
It's not a big thing to do, so I shouldn't be too worried about it, especially if you are copying from another source.

hth

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top