Results 1 to 9 of 9
  1. #1
    snoopy is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    53

    A from just for one user?

    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?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    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.

  3. #3
    snoopy is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    53
    Quote Originally Posted by June7 View Post
    Is this a split design? Backend is on a shared network drive?
    Yep

    Quote Originally Posted by June7 View Post
    Have a button that displays only when particular user is logged in. That button opens the form.
    That is exactly what I need. Could you provide a vba code?

  4. #4
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    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.

    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
    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.

    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

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    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.

  6. #6
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    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.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    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

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    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.

  9. #9
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    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

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 11-18-2013, 02:20 PM
  2. Replies: 1
    Last Post: 07-20-2012, 05:35 PM
  3. Replies: 3
    Last Post: 09-22-2011, 03:35 PM
  4. Replies: 1
    Last Post: 08-13-2011, 04:44 AM
  5. Replies: 8
    Last Post: 06-30-2010, 10:57 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums