Simple Login using MS Access 2007

Language

Hi.

I'm sharing this simple Login Form which I created using MS Access. I hope this will help Access newbies to become more comfortable with the program. I'm sure there are a number of ways to do this (perhaps much better than this) but I did what I could to make this simple and straight-forward.

I. Access Objects in this application:

A. Table:
1. tblUsers - table for application users

B. Forms:
1. frmLogin - start-up form
  **User Name - Erick, Password - erick
  **User Name - Billy , Password - billy

2. frmMenu - opens when user supplies correct user and password at Login form

C. Module
1. GVar - here is where I declared my Global variables 'strUser' and 'strRole'

II. Feature

frmLogin:
Prompts if the User combobox and/or Password text box has no entry
Prompts if the user types another name which isn't included in the list
Program closes when the user enters 3 consecutive wrong password
Login Form closes when correct password is supplied, greets the user, and opens the frmMenu.
Sets the value of strUser and strRole global variables which shall be used throughout user session.

frmMenu:
User name and role is displayed
Command button is enabled or disabled based on the value of strRole (enabled for 'Admin' and disabled for 'Encoder'

III. Tips for newbies
Learn and be more comfortable using the If... Then... Else  Statement
Learn how to declare variables and variable scoping (Private, Public, Global)
Dlookup function parameters and syntax

IV. Gotcha Moment
Docmd.Close in frmLogin prompts and runtime error 2585 so be sure to include the On Error Handler line

Hope this helps...

 

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Comments

Submitted byAnonymous (not verified)on Mon, 03/28/2011 - 16:31

hi anyone can answer pls.. how can i make my application in ms access in full scree mode?? hoping ur response thank u
Submitted bydissectoron Thu, 03/22/2012 - 18:47

hi guys,ive been working on trying to create a login form.
ms Access side:
-used a logininfo.mdb database with columns :username,password,job
vb 2008 side:
-login form with clerk rad button,manager rad button,username text box,password textbox and login button
now the challenge im having is that only the "Clerk" can login properly,ive used the same code for "Manager"
but just swapped the variables.however "manager" cant login
pls pls pls help asap,gotta submit this system soon.

Imports System.Data.OleDb
Public Class database
Public Sub login()
Dim con As New OleDb.OleDbConnection
con.ConnectionString = "PROVIDER=Microsoft.JET.OLEDB.4.0;Data Source = ..\logininfo.mdb"
Dim cmd As OleDbCommand = New OleDbCommand("SELECT job,username,password FROM login where username=? and password=?", con)

cmd.Parameters.AddWithValue("username", Form1.TextBox1.Text)
cmd.Parameters.AddWithValue("password", Form1.TextBox2.Text)

Try
con.Open()
Dim read As OleDbDataReader = cmd.ExecuteReader()

If read.HasRows Then
read.Read()

''validate clerk
If Form1.TextBox1.Text.ToLower() = read.Item("username").ToString And Form1.TextBox2.Text.ToLower = read.Item("password").ToString And Form1.rdbclerk.Checked Then
MsgBox("Login successful")
frmclk.ShowDialog()
Form1.Hide()

Else
If String.IsNullOrEmpty(Form1.TextBox1.Text) Xor String.IsNullOrEmpty(Form1.TextBox2.Text) Xor Form1.rdbclerk.Checked = False _
Xor Form1.rdbmgr.Checked Then
MsgBox("emp Login unsuccessful,pls type the correct details and select the correct usertype")
End If
End If

'validate manager
If Form1.TextBox1.Text.ToLower() = read.Item("username").ToString And Form1.TextBox2.Text.ToLower = read.Item("password").ToString And Form1.rdbmgr.Checked Then
MsgBox("Login successful")
frmclk.ShowDialog()
Form1.Hide()

Else
If String.IsNullOrEmpty(Form1.TextBox1.Text) Xor String.IsNullOrEmpty(Form1.TextBox2.Text) Xor Form1.rdbclerk.Checked = False _
Xor Form1.rdbclerk.Checked Then
MsgBox("emp Login unsuccessful,pls type the correct details and select the correct usertype")
End If
End If

Else
MsgBox("Login unsuccessful,no connection")
End If

read.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try

End Sub
End Class

Submitted byAnonymous (not verified)on Fri, 09/07/2012 - 17:04

Its great
Submitted byAnonymous (not verified)on Sun, 04/07/2013 - 20:29

Hello would you mind letting me know which webhost you're using? I've loaded your blog in 3 completely different web browsers and I must say this blog loads a lot faster then most. Can you recommend a good hosting provider at a reasonable price? Thanks a lot, I appreciate it!
Submitted byAnonymous (not verified)on Fri, 04/12/2013 - 16:35

i'm used this Simple Login using MS Access 2007 file but i faced a problem ; that is login only once it work then it stop working . l'm tried a lot of time , but nothing it happen
Submitted byAnonymous (not verified)on Fri, 06/28/2013 - 16:55

IT'S GOOD FOR MORE PEOPLES INCLUDING ME I SAY THANK U!!

Add new comment