Control Logins from and Access Database

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.
dwadsworAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
cedricdConnect With a Mentor Commented:
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
 
SendohCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.