Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    axd
    axd is offline
    New Coder
    Join Date
    Mar 2009
    Location
    Leeds, UK
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Visual Basic Help

    Hi, i don't know if I have the correct forum, so please be kind if I don't, and just point me in the right direction. This question will cover a bit of VBA and SQL. SQL I am familiar with, Visual Basic I am not, but here is my issue.

    I am follow a coding example for a login system for Microsoft Access. It all seems straight forward, the code checks whats been entered into the login box, and password box, then checks it against a table of existing users. If it finds the match then access is granted to the database/application.

    I wish to edit the code slightly so that the application also enters the users details into another table once he/she logs in, therefore creating a "logged in session status", that I can apply when the user logs in, and truncate out when they log off.

    The bit of coding I need is solely to enter whatever was entered into the username/password box upon successful authentication/login. Here is the code template I am using.

    Thanks to anybody with the necessary skillset to help me, in advance!

    Code:
    Private Sub cmdLogin_Click()
    
    Dim dbs As DAO.Database
    Dim rstUserPwd As Recordset
    Dim bFoundWatch As Boolean
    
    Set dbs = CurrentDb
    
    Set rstUserPwd = dbs.OpenRecordset("qryUserPwd")
    
    bFoundMatch = False
    
    If rstUserPwd.RecordCount > 0 Then
        rstUserPwd.MoveFirst
        
        'Check for matching records
        
        Do While rstUserPwd.EOF = False
        If rstUserPwd![UserName] = Form_frmLogin.txtUsername.Value And rstUserPwd![Password] = Form_frmLogin.txtpassword.Value Then
            bFoundMatch = True
            Exit Do
            
        End If
            rstUserPwd.MoveNext
        Loop
            
    End If
    
    If bFoundMatch = True Then
    'Open the next form here and close this one
    DoCmd.Close acForm, Me.Name
    DoCmd.OpenForm "frmNavigation"
    
    Else
    '
    MsgBox "Incorrect Username or Password"
    
    End If
    
    
    End Sub
    Last edited by axd; 02-28-2013 at 12:32 PM.

  • #2
    New to the CF scene
    Join Date
    Feb 2013
    Location
    Oklahoma
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    You want to record their username and password?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •