Results 1 to 9 of 9
  1. #1
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93

    Login form, to form


    Hi,
    I have a login form setup in a database that basically uses a table to check for username and password. I would like to be able to use that login information to automatically open a form, that also pulls with it the users login name, and then store the login name to each record the user enters. I am hung up on how to get the login information to transfer over to the form.
    Here is the code that controls the login process;
    Code:
    Option Compare Database
    
    Private Sub cbo_user_AfterUpdate()
        Me.txt_Password = Empty
        Me.txt_Password.Enabled = True
        Me.txt_Password.SetFocus
    End Sub
    
    Private Sub cmdOK_Click()
    'test the stored password is = to the manually entered password
    
        If Me.cbo_user.Column(2) = Me.txt_Password Then
            DoCmd.OpenForm "frmMainMenu", acNormal
    
            DoCmd.Close acForm, "frmLogin"
    
        Else 'wrong match
            MsgBox "Wrong password entered." & _
                vbCrLf & "Please re-enter password.", _
                vbExclamation, "Invalid Password"
            Me.txt_Password.SetFocus 'places the cursor in password control
        End If
    
    End Sub
    All I need is the username. And then I need it to autopopulate a field in a form. Anyone have any ideas? Thanks in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    There are any number of ways to go forward, depending on your specific needs. The easiest is probably to hide the login form instead of closing it, and you can access the user from anywhere in the application with:

    Forms!frmLogin.cbo_user
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    OK that sounds like a viable solution. Two questions, would hiding the form, make it inaccessible until closed? Also, would hiding it be a function of VB?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Not sure what you mean by inaccessible. Users would be able to see/use it, but VBA code, macros and queries would still be able to access it. To hide it you would set its Visible property to False, either in VBA or a macro.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    Ok. So currently the form has a button that runs this bit of code. Is is possible to have a macro that runs the code, then hides the form, and opens another?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I don't see the need for it. Just replace this line:

    DoCmd.Close acForm, "frmLogin"

    with

    Me.Visible = False
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    Ah ok. I do have that working now.
    How about for setting a text field on a form to the value of the username. Would I set the Default Setting of the text field to Forms!frmLogin.cbo_user? And I can then store that in a table?
    Thanks again!

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    That's likely what I would do, yes (I can't remember if it needs = before it).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Mclaren is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164
    I prefer to close the form after saving the User Login details to a public variable.

    In addition, i get the users :

    Computer name and System name so that i can track which machine was used and which user on the machine add,edited or deleted records.

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

Similar Threads

  1. Login form with nt login
    By hitesh_asrani_j in forum Forms
    Replies: 6
    Last Post: 09-22-2011, 11:43 AM
  2. LogIn Form to filter Main Form
    By ggs in forum Forms
    Replies: 5
    Last Post: 07-12-2011, 04:27 AM
  3. Login to a form?
    By tandkb in forum Forms
    Replies: 0
    Last Post: 04-25-2011, 06:05 PM
  4. Login form plus filter
    By bjelinski in forum Forms
    Replies: 1
    Last Post: 11-29-2010, 04:34 AM
  5. Login Form
    By Kookai in forum Access
    Replies: 3
    Last Post: 10-18-2010, 04:23 PM

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