vandaliarental
Technical User
I'm using the following code to determine which user gets what start form & permissions:
Public Function WhichMenu()
Dim str As String
Dim db As DAO.Database
Set db = CurrentDb
Const dbtext As Long = 10
Const dbboolean As Long = 1
str = "[Usr]='" & CurrentUser & "'"
str = DLookup("[FrmName]", "WhichMenu", str)
If str = "None" Then 'no menu; full permissions
ChangeProperty "StartupForm", dbtext, "(none)"
ChangeProperty "StartupShowDBWindow", dbboolean, True
ChangeProperty "StartupShowStatusBar", dbboolean, True
ChangeProperty "AllowBuiltinToolbars", dbboolean, True
ChangeProperty "AllowFullMenus", dbboolean, True
ChangeProperty "AllowBreakIntoCode", dbboolean, True
ChangeProperty "AllowSpecialKeys", dbboolean, True
ChangeProperty "AllowBypassKey", dbboolean, True
Else
ChangeProperty "StartupForm", dbtext, str
ChangeProperty "StartupShowDBWindow", dbboolean, False
ChangeProperty "StartupShowStatusBar", dbboolean, False
ChangeProperty "AllowBuiltinToolbars", dbboolean, False
ChangeProperty "AllowFullMenus", dbboolean, False
ChangeProperty "AllowBreakIntoCode", dbboolean, False
ChangeProperty "AllowSpecialKeys", dbboolean, False
ChangeProperty "AllowBypassKey", dbboolean, False
End If
Set db = Nothing
End Function
'===============
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
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
I'm calling the WhichMenu public function from the AutoExec macro.
My problem is that this code changes it for the next log in, not the current person logging in. For example, if a regular user logs in after the administrator (who has full edit rights), then the user has full edit rights. If the administrator logs in next, they end up with no edit rights.
I know I've missed something simple, but I just can't figure it out!
Thanks in advance,
Connie
Public Function WhichMenu()
Dim str As String
Dim db As DAO.Database
Set db = CurrentDb
Const dbtext As Long = 10
Const dbboolean As Long = 1
str = "[Usr]='" & CurrentUser & "'"
str = DLookup("[FrmName]", "WhichMenu", str)
If str = "None" Then 'no menu; full permissions
ChangeProperty "StartupForm", dbtext, "(none)"
ChangeProperty "StartupShowDBWindow", dbboolean, True
ChangeProperty "StartupShowStatusBar", dbboolean, True
ChangeProperty "AllowBuiltinToolbars", dbboolean, True
ChangeProperty "AllowFullMenus", dbboolean, True
ChangeProperty "AllowBreakIntoCode", dbboolean, True
ChangeProperty "AllowSpecialKeys", dbboolean, True
ChangeProperty "AllowBypassKey", dbboolean, True
Else
ChangeProperty "StartupForm", dbtext, str
ChangeProperty "StartupShowDBWindow", dbboolean, False
ChangeProperty "StartupShowStatusBar", dbboolean, False
ChangeProperty "AllowBuiltinToolbars", dbboolean, False
ChangeProperty "AllowFullMenus", dbboolean, False
ChangeProperty "AllowBreakIntoCode", dbboolean, False
ChangeProperty "AllowSpecialKeys", dbboolean, False
ChangeProperty "AllowBypassKey", dbboolean, False
End If
Set db = Nothing
End Function
'===============
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
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
I'm calling the WhichMenu public function from the AutoExec macro.
My problem is that this code changes it for the next log in, not the current person logging in. For example, if a regular user logs in after the administrator (who has full edit rights), then the user has full edit rights. If the administrator logs in next, they end up with no edit rights.
I know I've missed something simple, but I just can't figure it out!
Thanks in advance,
Connie