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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing db properties

Status
Not open for further replies.

vandaliarental

Technical User
Jul 17, 2000
84
US
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
 
I know that at least AllowBypassKey pertains to the next time you open the db. Read up on that, I know there's code on this forum for it. It requires that AllowBypassKey variable is set, the db closed, then reopened.



Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top