Needing a Log-In Form for a DB

  • Thread starter Thread starter TC
  • Start date Start date
T

TC

How are you going to stop someone from simply reading the usernames &
passwords out of your table?

TC
 
I have a ACCESS database that i need to have an Opening Login Form that the
person selects themself from a combo then puts in a password that both are
stored in a UserTable that has their name, a user number and a password in
it. THEN after they put in their password correctly they hit a button that
sends them to another form that is filtered by the by the User Number of the
person has logged in.

I am really really new to ACCESS and just learning VB so this may be a
simple task but cannot figure out where to start or how to make it function
correctly!!! Any assistance would be greatly appreciated!!! THANKS IN
ADVANCE!!!!
 
Chip said:
I have a ACCESS database that i need to have an Opening Login Form that the
person selects themself from a combo then puts in a password that both are
stored in a UserTable that has their name, a user number and a password in
it. THEN after they put in their password correctly they hit a button that
sends them to another form that is filtered by the by the User Number of the
person has logged in.

I am really really new to ACCESS and just learning VB so this may be a
simple task but cannot figure out where to start or how to make it function
correctly!!! Any assistance would be greatly appreciated!!! THANKS IN
ADVANCE!!!!

Something along the lines of...

Dim UserNumVar as Variant

UserNumVar = DLookup("[User Number]", "UserTable", "[UserName] = '" &
Me!NameComboBox & "' AND [Password] = '" & Me!Password & "'")

If IsNull(UserNumVar) = False Then
DoCmd.OpenForm "FormName",,,"[User Number] = " & UserNumVar
End If

However; home-grown security like this is worthless if any of your users are
familiar with Access. Do you have any users who know how to...

....hold down the shift key while opening the file to gain access to the db
window (including all tables)?

Press F11 after opening the file to gain access to the db window (including all
tables)?

Open any other file and then either link or import the tables in your file
thereby gaining access to all tables including the one with Users and Passwords?

You can throw some barriers up to make the above a bit harder to do, but the
only one that has any teeth at all is to implement Access built-in security and
of course that would render your home-grown solution unnecessary.
 
Hi Chip.

Try this in the after update event of the password entry
control

Private Sub txtPassword_AfterUpdate()

Dim strPassword, strUserName, strQuery, strSearchString As
String
Dim dbThis As Database
Dim rstUsers As Recordset


'assumptions:
'1. password entry control is txtPassword
'2. username entry control is cmbUsers
'3. User table is tblUsers, with fields User and Password
'4. the form you want to open is frmMain


'this records the entered username and password
strPassword = txtPassword.text
cmbUsers.setfocus
strUsername = cmbusers.text

'this goes out and gets the rows from the users table
that match the username
Set dbThis = CurrentDb
strQuery = "Select [tblUsers].* from [tblUsers] where
[tblUsers].[User] = " & chr$(39) & Combo68.Text & chr$(39)
& ";"
Set rstUsers = dbThis.OpenRecordset(strQuery,
dbOpenSnapshot)

With rstUsers
.MoveLast

'find the first record in the table that matches
both the username and password
strSearchString = "[ID] = " & strPassword
.FindFirst strSearchString

If .NoMatch Then
'this is not a valid combination of
username and password
msgbox("You will now be
electrocuted.",vbok+vbcritical)
Exit Sub
End If

'there was a match
'insert code here to close the form

DoCmd.Close 'close this form
DoCmd.OpenForm "frmMain", , ,
stLinkCriteria 'open the new one



End With

End Sub


Regards,

B
 
It is not for tight security reasons just to keep the people seeing their
own data. If they do open it and see the other peoples data, it is OK...
 
Back
Top