Solved

VB6 and Access

Posted on 2000-05-11
2
208 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

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

708 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

15 Experts available now in Live!

Get 1:1 Help Now