472,783 Members | 973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

User and Password in MS ACCESS

2
I am making a database program in MS Access I would to get help in giving a USER and PASSWORD in LOGIN Form. If the USER and PASSWORD is given in Table then we are entering the database else out of program or give an error.

I do not want to give the USER and PASSWORD to be mentioned in vb codes.

Please Help.


Kartik
Apr 4 '07 #1
14 14340
hi
if there are 2 textboxes namely name and psword and table name is logintable containing username and password fields which are texts then
then
If name = DLookup("username", "logintable", "[password]= '" & psword & "'") Then
do some thing
else Msgbox ""
Apr 4 '07 #2
Hi!!!

Is there any option because when i create a form linking to the table of login and enter everyone user and password, i want the user to to enter the username and password , if the user name and password matches the login table, then it should continue or else it should show an error message.

thanks & bye

Kartik
Apr 12 '07 #3
pks00
280 Expert 100+
enambo
Have u got a table created already?
here is an example

say u had a table called tblUsers, in it are two fields UserID and Pswd
Now a simple form example, u would have a form with two prompts txtUser and txtPswd and a button called cmdLogin

U would use the click event of cmdLogin to add your code

eg

Expand|Select|Wrap|Line Numbers
  1. private sub cmdLogin_Click()
  2.  
  3.     Dim sPswd as string
  4.  
  5.  
  6.     If IsNull(Me.txtUser) = True or IsNull(Me.txtPswd) = True then
  7.         msgbox "Please enter both a userid and password"
  8.         exit sub
  9.     end if
  10.  
  11.     'DLOOKUP returns null if no record found therefore give it a default value of ""
  12.     sPswd = NZ(DLOOKUP("Pswd","tblUsers","UserID='" & Me.txtUser & "'"),"")    
  13.  
  14.     If Me.txtPswd <> sPswd then
  15.         msgbox "Invalid UserID/Password combination"
  16.         exit sub
  17.     end if
  18.  
  19.     'Continue with normal successful login code
  20. end sub
  21.  


kartikss, sorry I havent quite undertstood your post, care to elaborate?
Apr 12 '07 #4
I have a question to add to this. Is it possible to carry that user ID for that user as long as they are logged into the DB so that anytime the user opens a form or report (ie also query) that it filters the data for that user.

I know this can be done using the Access built in security but I am trying to get away from that due to the environment.

Thanks in advance

Christian
Apr 18 '07 #5
pks00
280 Expert 100+
I have a question to add to this. Is it possible to carry that user ID for that user as long as they are logged into the DB so that anytime the user opens a form or report (ie also query) that it filters the data for that user.

I know this can be done using the Access built in security but I am trying to get away from that due to the environment.

Thanks in advance

Christian
define a global variable, then reference that
Apr 18 '07 #6
Shokoth
29
define a global variable, then reference that
How would we go about doing that.
What varialbe should we declare globally. is it the username (entered in a form), and the user name in the table?

then refer to it, where all the forms use that username?
Apr 19 '07 #7
Dude you may want to try this got this from the net, and i was able to use it

first create a table and name it tblEmployees, create the ff fields, lngEmpID(pk, AutoNumber),strEmpName(txt),strEmpPassword(txt),fu llname(txt),strAccess (text).

then create ur log on form frmLogon

using designview, insert a combobox, name it cboEmployee, and row source is SELECT tblEmployees.lngEmpID, tblEmployees.strEmpName FROM tblEmployees; on the after update event paste te ff code to set focus to textbox u wil create next,
Private Sub cboEmployee_AfterUpdate()
'After selecting user name set focus to password field
txtPassword.SetFocus
End Sub

Now create ur password text box,

name it txtPassword.

Now insert a button and name it cmdLogin

Paste the code below on the on click event

Private Sub cmdLogin_Click()

'Check to see if data is entered into the UserName combo box

If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If

'Check to see if data is entered into the password box

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If

'Check value of password in tblEmployees to see if this matches value chosen in combo box

If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then

lngMyEmpID = Me.cboEmployee.Value

'Close logon form and open splash screen

DoCmd.close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "Switchboard"
'Create your switchboard or change this to any other form u want the user to see upon log in

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If

'If User Enters incorrect password 3 times database will shutdown

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If

End Sub


You now have your Log in form

Hope i was able to help...good luck!
Apr 19 '07 #8
pks00
280 Expert 100+
rockdc1981

have a look at the code I posted. does that make sense to you?
its the same approach as the code you posted
Im hoping it makes sense to you so hopefully the OP understands it also
Apr 19 '07 #9
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command12_Click()
  2.  
  3.  
  4. If USER_ID = [Form_LOGIN MASTER].ID And PASSWORD = [Form_LOGIN MASTER].PWD Then
  5.  
  6. MsgBox (Form_Login.USER_ID + " - " + "WELCOME TO ENAM SECURITIES PVT LTD")
  7.  
  8.  
  9.  
  10.  Dim stDocName As String
  11.  Dim stLinkCriteria As String
  12.  
  13.   Me.Visible = False
  14.   DoCmd.OpenForm "STARTUP", acNormal, , , acFormEdit, acWindowNormal
  15.  
  16.  
  17.   stDocName = "STARTUP"
  18.   DoCmd.OpenForm stDocName, , , stLinkCriteria
  19.  
  20.  
  21. Else
  22.  
  23. MsgBox ("Incorrect User ID or Password - Please try again.")
  24.  
  25. End If
  26.  
  27.  
  28. End Sub 
PLS CHECK THE ABOVE CODE AND LET ME KNOW THE ERROR.
AS THIS WORK FINE. IT ACCEPTS ONLY FIRST RECORD AND NOT REST.
REST OF RECORD : I GET THE MESSAGE IE MsgBox ("Incorrect User ID or Password - Please try again.")

IS THERE ANY OTHER OPTION DO LET ME KNOW.

THANKS & BYE

KARTIK
Apr 19 '07 #10
meLady
27
Hello everyone,

Can anyone reply to kartikss's queries ... I am also interested in knowing the problems ... so, please reply to his question (^_^)
May 5 '07 #11
MMcCarthy
14,534 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command12_Click()
  2.  
  3.  
  4. If USER_ID = [Form_LOGIN MASTER].ID And PASSWORD = [Form_LOGIN MASTER].PWD Then
  5.  
  6. MsgBox (Form_Login.USER_ID + " - " + "WELCOME TO ENAM SECURITIES PVT LTD")
  7.  
  8.  
  9.  
  10.  Dim stDocName As String
  11.  Dim stLinkCriteria As String
  12.  
  13.   Me.Visible = False
  14.   DoCmd.OpenForm "STARTUP", acNormal, , , acFormEdit, acWindowNormal
  15.  
  16.  
  17.   stDocName = "STARTUP"
  18.   DoCmd.OpenForm stDocName, , , stLinkCriteria
  19.  
  20.  
  21. Else
  22.  
  23. MsgBox ("Incorrect User ID or Password - Please try again.")
  24.  
  25. End If
  26.  
  27.  
  28. End Sub 
PLS CHECK THE ABOVE CODE AND LET ME KNOW THE ERROR.
AS THIS WORK FINE. IT ACCEPTS ONLY FIRST RECORD AND NOT REST.
REST OF RECORD : I GET THE MESSAGE IE MsgBox ("Incorrect User ID or Password - Please try again.")

IS THERE ANY OTHER OPTION DO LET ME KNOW.

THANKS & BYE

KARTIK
How are you getting USER_ID and Password?
May 6 '07 #12
How are you getting USER_ID and Password?
Presently i am working with help of coding

for ex
Expand|Select|Wrap|Line Numbers
  1. private sub command1_click()
  2.  
  3. if id= form_login.id=kartik and pwd=form_login.password=123 or form_login.id=guest and form_login.password=g12 then
  4.  
  5. open the particular form
  6.  
  7. else
  8.  
  9. error message
  10.  
  11. endif
  12.  
  13. end sub
  14.  
  15.  
but now i want work with help of table name security control and table containing following details ie

userid (text), password (text), enable (y/n), visible (y/n)

if userid - enable = n then it should disable that option else it should enable
if userid - visible = n then it should disappear that option else it should appear

how do i work on this option

pls help me - urgently

if you require i will send the print screen of file.


Kartik
May 7 '07 #13
NeoPa
32,534 Expert Mod 16PB
How are you getting USER_ID and Password?
Presently i am working with help of coding

for ex
Expand|Select|Wrap|Line Numbers
  1. private sub command1_click()
  2.  
  3. if id= form_login.id=kartik and pwd=form_login.password=123 or form_login.id=guest and form_login.password=g12 then
  4.  
  5. open the particular form
  6.  
  7. else
  8.  
  9. error message
  10.  
  11. endif
  12.  
  13. end sub
  14.  
  15.  
but now i want work with help of table name security control and table containing following details ie

userid (text), password (text), enable (y/n), visible (y/n)

if userid - enable = n then it should disable that option else it should enable
if userid - visible = n then it should disappear that option else it should appear

how do i work on this option

pls help me - urgently

if you require i will send the print screen of file.


Kartik
Kartik,
If you do not reply correctly then you cannot expect any response.
You have not answered Mary's question.
You have simply asked the same question again and have posted some strange code with it that has never seen an Access database code window.
May 10 '07 #14
Denburt
1,356 Expert 1GB
I can only refer anyone back to post #4 I will repost the code that pks00 posted and try to add a few notes to help you understand. You need to take the values entered into the form then compare them to the information in the table. pks is using a function called DLookup, using this function he gathers the password information that is needed from the table for that particular user.

In this example you are telling DLookup to get the field information from "Pswd" in the table called "tblUsers" The final portion tells DLookup what the criteria is for pulling the one record you want so you can verify that the "Pswd" field matches the one on the form. Hence:"UserID='" & Me!txtUser & "'

The resulting password for me!txtUser will be stored in the variable sPswd for comparison purposes.

When in the VB window you can use the "debug.print sPswd" statement to verify you are picking up this information, the results will show in the immediate window if there are any to return.

Also in the VB window try highlighting the word DLookup and press F1.

Expand|Select|Wrap|Line Numbers
  1. private sub cmdLogin_Click()
  2.  
  3.     Dim sPswd as string
  4.  
  5.     If IsNull(Me!txtUser) = True or IsNull(Me!txtPswd) = True then
  6.         msgbox "Please enter both a userid and password"
  7.         exit sub
  8.     end if
  9.  
  10.     'DLOOKUP returns null if no record found therefore give it a default value of ""
  11.     sPswd = NZ(DLOOKUP("Pswd","tblUsers","UserID='" & Me!txtUser & "'"),"")    
  12. debug.print sPswd
  13.     If Me!txtPswd <> sPswd then
  14.         msgbox "Invalid UserID/Password combination"
  15.         exit sub
  16.     end if
  17.  
  18.     'Continue with normal successful login code
  19. end sub
Hope this helps.
May 10 '07 #15

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

Similar topics

4
by: Tim Daneliuk | last post by:
OK, I've Googled for this and cannot seem to quite find what I need. So, I turn to the Gentle Geniuses here for help. Here is what I need to do from within a script: Given a username and a...
0
by: Adam Fortuno KOVICK | last post by:
--Boundary_(ID_B/b4ffTtDNz/xCjv2UIigg) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline All, I've been attempting to assign a password...
1
by: notbob | last post by:
Newb here! Using 4.0.20 on Slack. Slogging through the official manual. At 2.4.3 Securing the Initial MySQL Accounts, I'm finally stopped cold while trying to follow instructions. Here's what I...
5
by: Dave Kolb | last post by:
Is there any other solution for an ASPNET application to access network resources other than running as SYSTEM, using delegation (a nightmare to get to work) or the COM+ solution? I cannot seem to...
8
by: Joe | last post by:
I check for the NTLogin of a user by Page.User.Identity.Name, but when I put the app on the server the value for Page.User.Identity.Name is "" I had the <allow users="*/> attribute commented...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
3
by: hary08 | last post by:
im doing a database for Hospital Admission, I have a log in form which prompt user for a password. The source of log in is to look for the values in my Table tblEmployees and match user name and...
4
by: mrouleau | last post by:
I am sorry if this is the wrong group to ask, if so please point me in the correct direction. My problem is I have an MDB file with user-level security on it (mdw). When i move it over to a...
13
JodiPhillips
by: JodiPhillips | last post by:
G'day, I have a silly and simple problem that I need some guidance with. Due to the way our network is set up, I am unable to use the group permissions for Access and have had to implement log...
14
by: chromis | last post by:
Hi, I've been trying to implement a more OOP oriented approach to dealing with user security on one of my websites, and I am trying to validate the user against an array of roles, however I am...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.