?
Solved

Verifying Logging on in a form

Posted on 2003-03-12
4
Medium Priority
?
207 Views
Last Modified: 2008-03-06
Hello,

I have a table with two cols- Username and Password.

I created a form with two fields - Username and Password and added a login button.

How do i get my button to check that what has been entered in the Username and Password fields is the same as what is held in my table, and then if okay carry out opening a form/s depending on what user level you are, and if not valid produce an error message.

It doesn't have to be highly secure but is just a means for limiting what is seen by different people.

Any help much appreciated.

Alli101
0
Comment
Question by:Alli101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Expert Comment

by:IanWorcester
ID: 8118651
You can use this:

The Username is in a combo (cmbUserName) box with 2 columns (the second is of 0cm width)

The Password is entered in txtPWord.


    If Me.txtPWord = Me.cmbUserName.Column(1) Then
        ' Valid PWord
    Else
        Beep
        MsgBox "Incorrect Password", vbExclamation
        Me.txtPWord.SetFocus
    End If


Not super secure, but works.

Hope it helps.
0
 
LVL 58
ID: 8118995
Below is the function I use to check my logins.  Should help get you started.

Jim.

'--------------------------------------------------------------------
' FUNCTION: FValidUser
' PURPOSE:  Return true if the user is valid
'--------------------------------------------------------------------
Function FValidUser(UserName As Variant, Pwd As Variant) As Integer
    Dim db As Database
    Dim rstUsers As Recordset
    Dim FUserExists As Integer
    Dim strName As String
    Dim strPassword As String

    Const Routine = "FValidUser"
    Const Version = "1.1.0"

    On Error GoTo FValidUserError
   
    FValidUser = False
   
    strName = Nz(UserName, "")
    strPassword = Nz(Pwd, "")

    Set db = CurrentDb()
    Set rstUsers = db.OpenRecordset("qrysysValidUser")
   
    If rstUsers.RecordCount > 0 Then
      rstUsers.MoveFirst
      Do Until rstUsers.EOF
        If strName = rstUsers!UserName And strPassword = rstUsers!Password Then
          FValidUser = True
          Exit Do
        End If
        rstUsers.MoveNext
      Loop
    End If

FValidUserExit:
    If Not rstUsers Is Nothing Then rstUsers.Close
    Set rstUsers = Nothing
    Set db = Nothing

    Exit Function

FValidUserError:
    UnexpectedError ModuleName, Routine, Version, Err, Error
    FValidUser = False
    Resume FValidUserExit

End Function
0
 
LVL 1

Accepted Solution

by:
IanWorcester earned 200 total points
ID: 8119029
I didn't mention, but the combo box should be fed from a query where the first column is Username and the second column is the password. Therefore the uname and password are contained in the same row of the combo box and the password can be referrenced once a username has been selected. This allows the correct password to be retreived for the correct user without having to open a recordset in code.
0
 

Author Comment

by:Alli101
ID: 8119299
Thankyou- worked a dream!

Thanks to everyone who responded.
:)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

770 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