Solved

VB6 and Access

Posted on 2000-05-11
2
211 Views
Last Modified: 2008-02-01
Trying to program a login screen in VB6. Need to find out how to get the application to check the username & password in an Access db to see if the user is a member, then if the username & password are correct display the entire record.
0
Comment
Question by:G_Funk
2 Comments
 

Accepted Solution

by:
CarmenSense earned 50 total points
ID: 2799800
Here is an example of using a DAO data control on the form:

' (Data2 data control is pointed to an Access table with containing fields:  'User ' & 'Password' )

Dim xUSER As String, xPASS As String
Dim Bad1 As Boolean
   
Bad1 = True
       
Data2.Recordset.FindFirst "User = '" & UCase(TDBText1) & "'"

If Not Data2.Recordset.NoMatch Then
        If UCase(TDBText2) = Data2.Recordset.Password Then
            Bad1 = False
        End If
    End If
       
    If Bad1 = True Then
        Beep
        MsgBox "Incorrect Password"
        TDBText1 = ""
        TDBText2 = ""
        TDBText1.SetFocus
    Else
        ' Continue Here by diplaying your entire record if desired.

        ' Loads Main menu form.
        Load Form2
        Form2.Show
        Unload Me
    End If
0
 
LVL 20

Expert Comment

by:hes
ID: 2801301
Two text boxes names name and password
Data1 control pointing to your access database

Data1.RecordSource = ("Select * from Table_Name  where name = '" & Name.text & "' ")
Data1.Refresh
If Not Data1.Recordset.EOF Then 'name is on file
  If Password.text <> Data1.Recordset("PASSWORD") Then
    ' invalid password
    ' do your invalid password code here
  Else
    ' good password
    ' do your code for a valid user here
  End If
End If
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

825 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