Solved

Control Logins from and Access Database

Posted on 1998-12-27
2
164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

751 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