Solved

Control Logins from and Access Database

Posted on 1998-12-27
2
163 Views
Last Modified: 2010-05-03
Does anybody have code available to Use the standard VB5 Login screen with a table of users and passwords from and Access 7.0 db.
0
Comment
Question by:dwadswor
2 Comments
 
LVL 3

Expert Comment

by:Sendoh
ID: 1452578
Hi !
Is it what you need here is the sample code on how to create login screen ??
If so please post your e-mail add and if not, state cleary what is your problem.

Thanks.
0
 
LVL 2

Accepted Solution

by:
cedricd earned 100 total points
ID: 1452579
here is the code i put on the visual basic login screen

Public cpt As Integer

Private Sub Bt_Cancel_Click()
    Continue = True
    Unload Me
    Util = ""
    Ok = Close_All
End Sub

Private Sub Bt_OK_Click()

    Dim poub As Integer
    Dim nb As Double
    Dim Fstatus As String
   
    Me.MousePointer = vbHourglass
   
    Util = UCase(Utilis.Text)
    If Not Already_Logged Then
       poub = 0
       Call Search_Dpt
       Fstatus = Find_Status
       If Fstatus = MANAGER Or Fstatus = GENMAN Then
          poub = Dpt
          Dpt = NUM_MAN
       End If
       Fstatus = Trim(Fstatus)
       If Fstatus = "VDR" Or Fstatus = "Guest" Or Fstatus = MANAGER Or Fstatus = GENMAN Or _
          Fstatus = "SPECIAL" Then
          If Dpt <> 0 Then
             If Password.Text = "" Then
                Password.Text = " "
             End If
             nb = crypt(Password.Text)
             If Not Verif_Passwd(nb) Then
                rc = MsgBox("Incorrect Password", vbCritical)
                Password.Text = ""
                Password.SetFocus
                cpt = cpt + 1
             Else
                Change_Done = True
                Ok = Init_Langage
                If Not Ok Then
                   Langage = "UK"
                End If
                Niveau = Find_Niveau
                Call logged(True)
                Continue = True
                Unload Me
             End If
          Else
             rc = MsgBox("User unknow ! Retry ", vbCritical)
             Utilis.Text = ""
             Password.Text = ""
             Utilis.SetFocus
             cpt = cpt + 1
          End If
       Else
             rc = MsgBox("You don't have the autority to run this program ! ", vbCritical)
             Utilis.Text = ""
             Password.Text = ""
             Utilis.SetFocus
             cpt = cpt + 1
       End If
       If poub <> 0 Then
          Dpt = poub
       End If
       If cpt > 2 Then
          Unload Me
       End If
    Else
           rc = MsgBox("This user is already logged !")
           Utilis.Text = ""
           Password.Text = ""
           Utilis.SetFocus
    End If
    Me.MousePointer = vbDefault
   
End Sub

Private Sub Form_Activate()
    Me.MousePointer = vbDefault
    Utilis.SetFocus
End Sub

Private Sub Form_Load()
    Change_Done = False
    cpt = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Me.MousePointer = vbDefault
End Sub

Private Sub Password_KeyPress(KeyAscii As Integer)
    Dim nb As Double
   
    If KeyAscii = 13 Then
       Call Bt_OK_Click
    End If
   
End Sub

Private Sub Utilis_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
       Password.SetFocus
    End If
End Sub

Function Verif_Passwd(nbre As Double) As Boolean
   
    Dim rs As Recordset
   
    On Error GoTo Error_Db
    Set rs = db.OpenRecordset("Select * from " + ACSS + " where login = " + Str(Dpt), dbOpenDynaset, 0, dbPessimistic)
    If rs!passwd = nbre Then
       Verif_Passwd = True
    Else
       Verif_Passwd = False
    End If
    rs.Close
    Exit Function
Error_Db:
    Verif_Passwd = False
    rc = MsgBox(Err.Description, vbCritical)
    On Error Resume Next
    rs.Close
End Function

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question