database window question

01-12-2004, 09:52 AM
I have a database that will have users who have really never used computers before and therefore it is desired that they only see the main form on startup of the database and not the database window. I know how to do this using the tools/startup option and I found in a search how to do it in code (down below), but the problem is there will also be users who might need to come in and make changes. The following code only will take effect the second time a user under a certain user name opens the database since it is setting startup properties. My question is Is there anyway to control the show database window property depending on the username on the main form's onload event? (i already have used an api to get the username so I don't need help with that part) Thanks for any help.

Private Sub Form_Load()
If CurrentUser = "Admin" Then
SetStartupProperties "(none)", True
SetStartupProperties "frmMain", False
End If

End Sub

Sub SetStartupProperties(strStartup As String, bAllow As Boolean)
Const DB_Text As Long = 10
Const DB_Boolean As Long = 1
ChangeProperty "StartupForm", DB_Text, strStartup
ChangeProperty "StartupShowDBWindow", DB_Boolean, bAllow
ChangeProperty "StartupShowStatusBar", DB_Boolean, bAllow
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, True
ChangeProperty "AllowFullMenus", DB_Boolean, True
ChangeProperty "AllowBreakIntoCode", DB_Boolean, True
ChangeProperty "AllowSpecialKeys", DB_Boolean, bAllow
ChangeProperty "AllowBypassKey", DB_Boolean, bAllow
ChangeProperty "AllowToolbarChanges", DB_Boolean, True
End Sub

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

Exit Function

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

01-12-2004, 09:57 AM
Couldn't you have a user's rights table. Basically, have "manager" levels and "user" levels. If the logged in user is a "manager" then set these specific rights, if it they are a standard user, give them more restricted rights.

I know you can have various restrictions in MS Access. It has been a while since I personally did anything with it:)...but I know it can be done. But basically, when the user logs in, initially check your user rights table...if the ID and password match check their status (could be a third field on your user rights table) then act accordingly.

Actually, in terms of the Database Window...I am not sure if that can be a log in condition. But I would imagine it is possible.

01-12-2004, 10:06 AM
I haven't been able to find a way that you can do this with the database window. It seems to be only something you can set in the startup menu. Once the database is opened it doesn't seem like you can get rid of the database window based on the user.

01-12-2004, 10:48 AM
It actually might not be possible. I know you can set the database window to hidden or not hidden, but I am not sure if there is a way to dynamically select whether it is viewable via user permissions.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum