Results 1 to 6 of 6

Thread: Login Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    9

    Question

    I used the wizard in VB to create a login to limit access to the application via a username and password, but it doesn't work correctly. Does someone have an example I could look at.

  2. #2

    Wink Simple login dialogue for application

    Public Sub GetDBPath()

    'The subroutine to open access database

    Open "location.ini" For Input As #1
    Open "system.ini" For Input As #2
    Input #1, pth
    Input #2, sys
    Close #1
    Close #2
    dbPath = pth
    sysPath = sys
    DBEngine.SystemDB = sysPath
    DBEngine.DefaultUser = "username"
    DBEngine.DefaultPassword = "password"

    Set dbs = OpenDatabase(dbPath)
    Exit Sub

    errorhandler:
    Stop
    End Sub
    _________________________________________________

    Private Sub cmdOK_Click()

    'Design the login screen (2 cmd buttons/1 txt box/1 combo
    'Select the Department from combo box.
    'type password into txtbox

    Screen.MousePointer = vbHourglass
    pass = txtPassword.Text
    Group = cboDept.text
    GetDBPath 'calls the routing above to open the database

    'check the password

    Set passrec = dbs.OpenRecordset("Select [Password] FROM tbl_pass WHERE [Department]='" & Group & "'")

    passtemp = passrec![Password]
    dbs.Close


    If UCase(pass) = UCase(passtemp) Then
    enable menus / show forms etc...
    Else
    Unload frmLogin
    disable menus / show forms etc...
    End If

    Screen.MousePointer = vbDefault
    End Sub

    ____________________________________________
    Bob

    PS. I hope I haven't misunderstood your request entirely !!









  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    9

    Question

    How can I set security levels?

  4. #4

    Smile Security Levels

    Just add a field to your database [Security Levels] and depending on who logs in and what security level they are you enable more or less functionality.
    Bob

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    9

    Question

    What is the code to use the username to determine security levels if my table is called security?

  6. #6

    Red face Code is very straightforward ........

    The code is very similar to what I have posted earlier ... It will depend on whether you are limiting access by User or by Department.
    Add a field [Access Level] to the table that stores the Usernames/Depts/Passwords then read it into the Recordset and then perform actions depending on the value stored in the [Access Level] field

    ie..... use the earlier code but amend to something like this....


    .......
    .......
    GetDBPath 'calls the routing above to open the database

    Set passrec = dbs.OpenRecordset("Select * FROM tbl_pass WHERE [Department]='" & Group & "'")

    passtemp = passrec![Password]
    accessvar = passrec![Access Level]
    dbs.Close


    If UCase(pass) = UCase(passtemp) Then
    Select Case accessvar
    Case accessvar = 1
    .........
    Case accessvar = 2
    .........
    Case accessvar = 3
    .........
    End Select
    Else
    Unload frmLogin
    disable menus / show forms etc...
    End If

    Screen.MousePointer = vbDefault


    ____________________________________________________




Posting Permissions

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



Click Here to Expand Forum to Full Width