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
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 ""
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
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 -
private sub cmdLogin_Click()
-
-
Dim sPswd as string
-
-
-
If IsNull(Me.txtUser) = True or IsNull(Me.txtPswd) = True then
-
msgbox "Please enter both a userid and password"
-
exit sub
-
end if
-
-
'DLOOKUP returns null if no record found therefore give it a default value of ""
-
sPswd = NZ(DLOOKUP("Pswd","tblUsers","UserID='" & Me.txtUser & "'"),"")
-
-
If Me.txtPswd <> sPswd then
-
msgbox "Invalid UserID/Password combination"
-
exit sub
-
end if
-
-
'Continue with normal successful login code
-
end sub
-
kartikss, sorry I havent quite undertstood your post, care to elaborate?
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
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
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?
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!
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
- Private Sub Command12_Click()
-
-
-
If USER_ID = [Form_LOGIN MASTER].ID And PASSWORD = [Form_LOGIN MASTER].PWD Then
-
-
MsgBox (Form_Login.USER_ID + " - " + "WELCOME TO ENAM SECURITIES PVT LTD")
-
-
-
-
Dim stDocName As String
-
Dim stLinkCriteria As String
-
-
Me.Visible = False
-
DoCmd.OpenForm "STARTUP", acNormal, , , acFormEdit, acWindowNormal
-
-
-
stDocName = "STARTUP"
-
DoCmd.OpenForm stDocName, , , stLinkCriteria
-
-
-
Else
-
-
MsgBox ("Incorrect User ID or Password - Please try again.")
-
-
End If
-
-
-
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
Hello everyone,
Can anyone reply to kartikss's queries ... I am also interested in knowing the problems ... so, please reply to his question (^_^)
- Private Sub Command12_Click()
-
-
-
If USER_ID = [Form_LOGIN MASTER].ID And PASSWORD = [Form_LOGIN MASTER].PWD Then
-
-
MsgBox (Form_Login.USER_ID + " - " + "WELCOME TO ENAM SECURITIES PVT LTD")
-
-
-
-
Dim stDocName As String
-
Dim stLinkCriteria As String
-
-
Me.Visible = False
-
DoCmd.OpenForm "STARTUP", acNormal, , , acFormEdit, acWindowNormal
-
-
-
stDocName = "STARTUP"
-
DoCmd.OpenForm stDocName, , , stLinkCriteria
-
-
-
Else
-
-
MsgBox ("Incorrect User ID or Password - Please try again.")
-
-
End If
-
-
-
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?
How are you getting USER_ID and Password?
Presently i am working with help of coding
for ex -
private sub command1_click()
-
-
if id= form_login.id=kartik and pwd=form_login.password=123 or form_login.id=guest and form_login.password=g12 then
-
-
open the particular form
-
-
else
-
-
error message
-
-
endif
-
-
end sub
-
-
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
NeoPa 32,534
Expert Mod 16PB
How are you getting USER_ID and Password?
Presently i am working with help of coding
for ex -
private sub command1_click()
-
-
if id= form_login.id=kartik and pwd=form_login.password=123 or form_login.id=guest and form_login.password=g12 then
-
-
open the particular form
-
-
else
-
-
error message
-
-
endif
-
-
end sub
-
-
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.
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. - private sub cmdLogin_Click()
-
-
Dim sPswd as string
-
-
If IsNull(Me!txtUser) = True or IsNull(Me!txtPswd) = True then
-
msgbox "Please enter both a userid and password"
-
exit sub
-
end if
-
-
'DLOOKUP returns null if no record found therefore give it a default value of ""
-
sPswd = NZ(DLOOKUP("Pswd","tblUsers","UserID='" & Me!txtUser & "'"),"")
-
debug.print sPswd
-
If Me!txtPswd <> sPswd then
-
msgbox "Invalid UserID/Password combination"
-
exit sub
-
end if
-
-
'Continue with normal successful login code
-
end sub
Hope this helps.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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=()=>{
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
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...
| |