test password open northwind

J

Jim Oswell

What I am trying to do is create a vb.exe that will:
First test for valid username & password names
and passwords are listed in "users" Northwind.mdb
If valid name and password are entered on form1
Then
Open northwind.mdb and display a list of the
tables located in northwind.mdb

Folder C:\L_DATA
new table in northwind.mdb = "users"
In Table "users"
USER NAME joswell
PASSWORD jim111
CODE

FORM1 CODE
Option Explicit

Public LoginOK As Boolean


Private Sub cmdCancel_Click()
'set the global var to false to denote a failed login
LoginOK = False
Me.Hide ' Hides the login form
End ' Exits the program
End Sub

Private Sub cmdOK_Click()
Dim tries As Long
'check for correct password and user name in the
database USERS table
Datusers.Recordset.FindFirst "user = '" &
txtUserName.Text & "'"
If txtPassword = Datusers.Recordset.Fields("password")
And txtUserName = Datusers.Recordset.Fields("user") Then
LoginOK = True
MsgBox "Login Successful", vbOKOnly
'If login is successful, trigger the opening of the next
form.

DB.OPEN
Me.Hide ' Hide The Login Form
Else
' If the login is incorrect advise the user.
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub

Private Sub Form_Load()

' Set application path and database etc.
Datusers.DatabaseName = App.Path & "\Northwind.mdb"
Datusers.RecordSource = "Users"

End Sub

MODULE 1 CODE

Sub openNW()
Dim appAccess As New Access.Application
Const conPath As String = "C:\L_DATA\Northwind.mdb"

With appAccess
' Open the Northwind sample database.
OpenCurrentDatabase conPath
End With
End Sub

Problems
First I get an error message that a installable ISAM
cannot be found reference DAO 3.51

Second after entering name & password and clicking OK
Error message "OBJECT VARIABLE OR WITH
BLOCK NOT SET" is displayed.

THANKS IN ADVANCE FOR YOUR HELP
I HAVE A CO-WORKER IN GREAT NEED OF SOLUTION

Jim Oswell
 
J

j oswell

dao 3.51 checked
code reads as follows

Option Explicit
Public LoginOK As Boolean
Private Sub cmdCancel_Click()
'set the global var to false to denote a failed login
LoginOK = False
Me.Hide ' Hides the login form
End ' Exits the program
End Sub

Private Sub cmdOK_Click()
Dim tries As Long
'check for correct password and user name in the
database USERS table
Datusers.Recordset.FindFirst "user = '" &
txtUserName.Text & "'"
If txtPassword = Datusers.Recordset.Fields("password")
And txtUserName = Datusers.Recordset.Fields("user") Then
LoginOK = True
MsgBox "Login Successful", vbOKOnly
'If login is successful, trigger the opening of db
"northwind.mdb".open
Me.Hide ' Hide The Login Form
End If
End Sub

'**********************************************************
************************************
Sub openNW()
Dim AppAccess As New Access.Application
Set AppAccess = CreateObject "Access.Application") 'init.
Const conPath As String = "C:\L_DATA\Northwind.mdb"
With AppAccess
' Open the Northwind sample database.
OpenCurrentDatabase conPathEnd With
End Sub
'*********************************************************
************************************
Else
' If the login is incorrect advise the user.
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub

Private Sub Form_Load()
' Set application path and database etc.
Datusers.DatabaseName = App.Path & "\Northwind.mdb"
Datusers.RecordSource = "Users"
End Sub

something is still not right
db connected not visable

Thanks for responding
I am trying to learn but sometimes I cannot make anything
work

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top