473,320 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Login system for ms access

I have created a login system for my access 2007 database with the VBA code below. I would like to add as much as many users name and password to the table that stores the user name and password using the code. Again, I would like to add user groups and permissions using the code. When I add a new user name and password to the existing one in the table by opening it, the code can only find the very first one. please help me

Expand|Select|Wrap|Line Numbers
  1. Dim wsp As Workspace
  2. Dim newUser As User, tempGrp As Group
  3. Dim UsrName As String, PersonalID As String
  4. Dim Password As String
  5. Dim Saved_Name As String ' This variable contains saved usrname from file
  6. Dim Saved_pass As String 'This variable contains saved passed from file
  7. Dim count As Variant
  8. On Error Resume Next
  9.  
  10. Set wsp = DBEngine.Workspaces(0)
  11. Open "tblemployees" For Input As #1 'We open file with data we need
  12. Line Input #1, UsrName ' We read username from file'
  13. Line Input #1, Password 'We read password from file'
  14. Close #1 ' We close the file'
  15.  
  16. UsrName:
  17.     UsrName = InputBox("Please, enter Your name.", "Introduce yourself", "") ' 1 to 50 characters.
  18.     If UsrName = "" Then
  19.     Response = MsgBox("To Continue with the programme, You need to introduce Yourself." & vbCrLf & "Do you wish to continue?", vbYesNo)
  20.     If Response = vbYes Then GoTo UsrName
  21.     If Response = vbNo Then
  22.     MsgBox "we are sorry,You do not wish to proceed." & vbCrLf & "We wish you a good day", vbInformation
  23.  
  24.     Beep
  25.     Application.Quit
  26.     End
  27.  
  28.  
  29.     End If
  30.     End If
  31. Password:
  32.     Password = InputBox("Please, enter a password for " & UsrName & ".", "Login", "")
  33.     If Password = " " Then
  34.     Response = MsgBox("To Continue with the programe, You need to enter your password." & vbCrLf & "Do you wish to continue?", vbYesNo)
  35.     If Response = vbYes Then GoTo Password
  36.     If Response = vbNo Then
  37.     MsgBox "we are sorry,You do not wish to proceed." & vbCrLf & "We wish you a good day", vbInformation
  38.     End
  39.     End If
  40.     End If
  41.  
  42.     Set rstfees1 = CurrentDb.OpenRecordset("tblemployees")
  43.     rstfees1.Index = "Primarykey"
  44.     rstfees1.Seek "=", lngEmpID, Saved_Name, Saved_pass
  45.     With rstfees1
  46.     If (DLookup("Saved_Name", "tblemployees")) = UsrName And (DLookup("Saved_pass", "tblemployees")) = Password Then
  47.     MsgBox "Good day" & " " & UsrName & "." & vbCrLf & "Welcome to our programme, we wish you pleasant work"
  48.     DoCmd.OpenForm "switchboard"
  49.  
  50.     Else
  51.     MsgBox "We are sorry, usrname and or password are not correct. Please Try Again", vbCritical + vbOKOnly, "Error "
  52.     Application.Quit
Mar 21 '11 #1
1 2587
NeoPa
32,556 Expert Mod 16PB
You need to provide more explanation if you want help here. Simply dumping 52 lines of code and expecting someone to work out what it's supposed to do is not enough.

I've looked through your code (nevertheless) and it needs a lot of work. There are too many problems to list them all, but I'll drop a few in and see where that leads you :
  1. The file processing reads in only a single set of data. This may be what you want, but without the explanation it's hard to tell. You should at least be aware of it.
  2. This same processing stores the values read in UsrName & Password instead of Saved_Name and Saved_Pass which I think you wanted.
  3. Line #33 compares the value to a space and not an empty string. You should check > "" to avoid tripping up on Null data.
  4. As a general rule (if you're at all serious about security) passwords should never be stored as plain text. Neither in the file nor in the table.
  5. For lines #35 & #36 it makes no sense to check the response against vbNo after you know it's not vbYes. It cannot be anything other than vbNo.
  6. Never include On Error Resume Next in your code until it is past the development stage. This simply makes debugging more difficult for you and makes it harder for you to see if any errors are occurring.
That's enough to go on for now.

As a hint for the future, NEVER post code unless it has Option Explicit set at the top of the module (This needn't always be included in what you post) and a compilation has at least been attempted. If the compilation fails we need to know what the error message was and where it occurred in the code.
Mar 22 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Geiregat Jonas | last post by:
I'm running a linux system I would like to create a login system based upon the users and passwd of my linux box how could I do this ?
18
by: R. Rajesh Jeba Anbiah | last post by:
This is regarding secure login implementation in PHP. I'm trying to understand <http://mail.yahoo.com/> If I understand right, they're passing the md5 hash instead of the password itself. But, I...
6
by: R. Rajesh Jeba Anbiah | last post by:
Q: How to implement a login system? A: Use sessions. When the user logins, store the session id in the database and then compare the current session id with the one stored in the database on every...
6
by: andRea | last post by:
Hi all! Anybody knows how is possible detect the Novell login in Access? Thank you all andRea
0
by: Lawrance | last post by:
DearAll: I want to control account login system once at the same time. Can I use session or application to solve this situation, even user close browser or computer crash? Best Regards,...
8
by: frizzle | last post by:
Hi group, I need a login system for some 'private' pages. Users should be pulled from a mysql DB. Now, i've read a lot on login systems, and somehow there's _always_ the discussion with...
7
by: Me | last post by:
Am new to vb dotnet and although I like what I've seen sofar, I am experiencing pblms with system access violation "attempt to read write protected memory". This error happens when I open a...
1
blyxx86
by: blyxx86 | last post by:
Is setting up a username/password system very difficult? What is the code, like Environ(), but specific for the username used to log into the database? We are going to be using my database at...
13
by: Apostle | last post by:
Hi all, after thinking for sometimes, I thought it will be great opportunity to learn if I will start from scratch and build my own register/login system. Here is the thread that I will be posting...
1
by: munkee | last post by:
I have modified Richard Rensel's Security Demo 2000 in order to produce a custom user login system. One of the aspects which I am succesfully using is the basic user grouping level: Access ID -...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.