Solved

Control Logins from and Access Database

Posted on 1998-12-27
2
160 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now