hey access heroes,
I have a simple question. i would like to add a form, which just one user see (it's a multi user db). How can I do this?
hey access heroes,
I have a simple question. i would like to add a form, which just one user see (it's a multi user db). How can I do this?
Is this a split design? Backend is on a shared network drive?
Is there a login procedure for the users?
Have a button that displays only when particular user is logged in. That button opens the form.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
If their windows login name is unique... you could use the environ... I don't know if this would work... I'm sure June has either a better way or can snazz this bit up a bit.
OR possibly use a select case, if you wanted different forms for different people... In the primitive sense I think this would work but become a management nightmare as things get added on.Code:Public Sub "yourbuttonname"_Click() if Environ("username") = "John Smith" then DoCmd.Close acForm, "name of current form" ' IF you want the main form to close, if not remove this line. DoCmd.OpenForm "name of specific form for user" else msgbox Environ("username") & " is not authorized to view this form!" end if
in this case my signiture is ringing true lol
Oh and in the past using A2003, ive had to use this for some reason.... But you should try it without this part
Code:'This function is used to allow the use of the Environ function in Access 2003 Public Function Environ(username) On Error GoTo Err_Environ Environ = VBA.Environ(username) Exit_Environ: Exit Function Err_Environ: MsgBox Err.Number & " - " & Err.Description Resume Exit_Environ End Function Public Function GetUser() GetUser = Environ("USERNAME") End Function
Just where I was heading, Redbull, good start.
Access doesn't recognize the VBA Environ function. So one way to get the USERNAME to display on a form is build a custom function using the VBA Environ and call the custom function from a textbox ControlSource. However, I think the two-tiered function may be overdoing it.
If you don't want to hard code the user authorization, build a table of users and their permissions. Then code could be like:
strPermission = Nz(DLookup("Permission", "tblUsers", "User='" & Environ("USERNAME")) & "'", "")
If strPermission = "" Then
MsgBox "Not a registered user. Contact Administrator"
Else
If strPermission = "some value" Then
'code to open form or do something else
End If
End If
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I like that. I was also thinking about it... he could really have a 3rd database with that form. if the username = XXX then download the 3rd database from the shared drive and have the form & data be linked. Thats how I manage credentials.. It is a front end / Back end and a separate database that holds the users credentials for everything. When the front end looks for the credentials, it will build the linked tables because of this snazzy bit.
If Err.Number = 3265 Then
DoCmd.TransferDatabase acLink, "Microsoft Access", Environ("userprofile") & "\My Documents\Lift\Credentials.mdb", acTable, "tblCred", "tblCred"
DoCmd.TransferDatabase acLink, "Microsoft Access", Environ("userprofile") & "\My Documents\Lift\Credentials.mdb", acTable, "tblWebCreds", "tblWebCreds"
End If
And from then on, the credentials are linked and working. ANNND we can update the front end without having the users reset their creds over and over again.
Or, and this is really simple, if the 'special' user, and only the 'special' user, accesses the app from one PC, you could simply Import this 'special' Form into his/her copy of the Front End!
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007
I prefer not to maintain various versions of the same frontend. I just code availability of buttons.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I don't do it as rule, either, but a one-off Form for one user might be easier to do!
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007