** Admin Edit - Thread split from To search record **
alright,i will try...
Another is I want to add user login form in my database,I know that there are many threads about this but I still dont understand it...I already create table name [UserConfig]
where it has the following -
lngID,PK,Autonumber
-
UserName,Text
-
IsAdmin,Text
-
Password,Text
-
and a form name [frmLogin] with the following -
cmbUserName,ComboBox
-
txtPassword,TextBox
-
btnLogin,Button
-
I already insert this code -
Private Sub btnLogin_Click()
-
-
If IsNull(Me.cmbUserName) Or Me.cmbUserName = "" Then
-
MsgBox "Please enter UserName", vbOKOnly, "Required"
-
Me.cmbUserName.SetFocus
-
Exit Sub
-
End If
-
-
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
-
MsgBox "Please enter Password", vbOKOnly, "Required"
-
Me.txtPassword.SetFocus
-
Exit Sub
-
End If
-
-
If Me.txtPassword.Value = DLookup("Password", "UserConfig", "[lngID]=" & Me.cmbUserName.Value) Then
-
lngID = Me.cmbUserName.Value
-
-
Else
-
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry"
-
Me.txtPassword.SetFocus
-
End If
-
-
Exit Sub
-
-
intLogonAttempts = intLogonAttempts + 1
-
If intLogonAttempts > 3 Then
-
MsgBox "You do no have access to this database.", vbCritical, "Restricted Access!"
-
Application.Quit
-
End If
-
The problem im having are I dont where to put this code which to compare the level of user so that some user will be able to open all form -
If DLookup("IsAdmin", "UserConfig", "[lngID]=" & Me.cmbUserName.Value = "Yes") Then
-
...'Coding for allowing access to application/form(I do not know)
-
Else
-
-
If DLookup("IsAdmin", "UserConfig", "[lngID]=" & Me.cmbUserName.Value = "No") Then
-
...'Coding for allowing access to application/form(I do not know)
-
End If
-
-
DoCmd.OpenForm "MAIN MENU"
-
DoCmd.Close acForm, "frmLogin", acSaveNo
-
...and how to to make the coding for allowing certain application/form for certain user...For example,adminis trator will have access for all but the user only have access for search form....
I try this code to test to see it work or not -
If DLookup("IsAdmin", "UserConfig", "[lngID]=" & Me.cmbUserName.Value = "Yes") Then
-
MsgBox "You are a Administrator", vbOKOnly
-
Else
-
-
If DLookup("IsAdmin", "UserConfig", "[lngID]=" & Me.cmbUserName.Value = "No") Then
-
MsgBox "You are a User", vbOKOnly
-
Exit Sub
-
End If
-
-
DoCmd.OpenForm "MAIN MENU"
-
DoCmd.Close acForm, "frmLogin", acSaveNo
-
but when click the button nothing happen...
Sorry for asking this question again....
7 1909 NeoPa 32,564
Recognized Expert Moderator MVP
Let me start by saying that, because you have included a good deal of relevant info in your first post on this subject, helping you along will be MUCH easier than before. We win - You win :)
Let's start by highlighting the first issue I see then (We can move onto others when I find them).
When testing form control values for being empty, simply check IsNull() for the name of the control. The .Value is the default property anyway. Thus, your first batch could be : - If IsNull(Me.cmbUserName) Then
-
MsgBox "Please enter UserName", vbOKOnly, "Required"
-
Me.cmbUserName.SetFocus
-
Exit Sub
-
End If
NeoPa 32,564
Recognized Expert Moderator MVP
After line #13 you need to add in :
Otherwise, it will remember failed attempts, even after a successful logon.
By the way, you don't include the Dimming of intLogonAttempt s. I assume it is module level.
NeoPa 32,564
Recognized Expert Moderator MVP
How you manage access to various objects (forms etc) is really very much dependent on your intentions and design. For instance, where and how are you storing the operator's identity?
The checks should be done whenever attempting to access a resource. This can either be hard-coded into the resource itself (a form's Form_Open() event) or into the calling code that opens the form. An alternative to hard-coding is to dhave a system where your configuration is stored in a table.
This the code after few changes,not much... -
Option Compare Database
-
-
Private Sub Command6_Click()
-
-
Dim intLogonAttempts As Integer
-
-
If IsNull(Me.cmbUserName) Or Me.cmbUserName = "" Then
-
MsgBox "Please enter UserName", vbOKOnly, "Required"
-
Me.cmbUserName.SetFocus
-
Exit Sub
-
End If
-
-
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
-
MsgBox "Please enter Password", vbOKOnly, "Required"
-
Me.txtPassword.SetFocus
-
Exit Sub
-
End If
-
-
If Me.txtPassword.Value = DLookup("Password", "UserConfig", "[lngID]=" & Me.cmbUserName.Value) Then
-
lngID = Me.cmbUserName.Value
-
intLogonAttempts = 0
-
Else
-
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry"
-
Me.txtPassword.SetFocus
-
End If
-
Exit Sub
-
-
intLogonAttempts = intLogonAttempts + 1
-
If intLogonAttempts > 3 Then
-
MsgBox "You do no have access to this database.", vbCritical, "Restricted Access!"
-
Application.Quit
-
End If
-
-
End Sub
-
How you manage access to various objects (forms etc) is really very much dependent on your intentions and design. For instance, where and how are you storing the operator's identity?
The checks should be done whenever attempting to access a resource. This can either be hard-coded into the resource itself (a form's Form_Open() event) or into the calling code that opens the form. An alternative to hard-coding is to dhave a system where your configuration is stored in a table.
I store the operator identity in a table as i mention previously...hm m...I dont really understand,can u give some example about this "An alternative to hard-coding is to dhave a system where your configuration is stored in a table."
I want administrator to have the access to add,update,dele te and search form while user only have the access for the search form...do i need to insert this in the table because there are about many form...
NeoPa 32,564
Recognized Expert Moderator MVP
From your psted code I would make the following comments : - Add the line "Option Explicit" after "Option Compare Database".
- Set this as the default (From VBA Editor select Tools / Options / Editor Tab / Require Variable Declaration).
- Compile your code (always) before posting it. This avoids confusion as we expect any posted code to be compiled unless otherwise stated.
- You are still comparing controls against "". As far as I'm aware this is never a possible value. This is not exactly wrong. It's simply wasting time and makes the code harder to understand easily.
- intLogonAttempt s needs to be declared in one of two ways (The way you have it won't work as there is no looping within the procedure itself. Every time it is called intLogonAttempt s will be reset to 0 before the code executes).
- Declare it as Private in the module OUTSIDE of any procedures (preferably before any of your code).
- Declare it as Static within the procedure itself. Simply replace Dim intLogonAttempt s As Integer with Static intLogonAttempt s As Integer.
I recommend looking up Private & Static in Access Help. NeoPa 32,564
Recognized Expert Moderator MVP
I store the operator identity in a table as i mention previously...hm m...I dont really understand,can u give some example about this
I am referring to something which remembers, not what operators are available, but which operator has already been successfully verified and is now logged on. This is session level information. It would not be a good idea to store this in a table, as otherwise other users would have access to it simply because someone else is already logged on at another PC. "An alternative to hard-coding is to have a system where your configuration is stored in a table."
I want administrator to have the access to add,update,dele te and search form while user only have the access for the search form...do i need to insert this in the table because there are about many form...
If you want different forms to have different sets of operators that can access them, then you will either need to check the logged in operator (they shouldn't need to log in again every time they go to a new form) within each different form, or you will need to design a system based on a table which stores which operators are allowed for each form.
Does that make it clearer?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Simon |
last post by:
Hi,
I have a Login.php page that logs the user in and out.
I has two forms within the page, (depending on what we are trying to do),
either one to log in or out.
The form calls itself using a post method and either logs the user in our
out given the information from the form.
but every pages use sessions and cookies, if the user is...
|
by: John Davis |
last post by:
I put a little login (username and password textfields) in a web page, and
once the user able to login, I want the username and password textfields
will disappear, and replace with text " has Login!]" in the same
position.
My question is how to make the username and password textfields disappear
and replace with " has Login!]" in the same...
|
by: Wayne Smith |
last post by:
Applies to: Microsoft FrontPage 2000, Microsoft Access 2000, IIS 5.0
Operating System: Microsoft Windows 2000 Professional
I am trying to protect a portion of a web site by allowing users to register a username and password & then login with those details, but so far I am having only marginal success. I am far from an expert on ASP...
|
by: Dam6 |
last post by:
Okay...
Using vb .net within DW MX2004, connecting to an access database:
Background: I have created a simple login.aspx page that is supposed to
re-direct to default.aspx using FormsAuthentication.RedirectFromLoginPage.
The data is correct from testing the dataset etc and the page also informs
me that I have entered an incorrect user /...
|
by: Bob |
last post by:
I haver a user login form (winforms app using vs2005 in VB.NET). After
succesfull validayion of user I want to open a first form and close the
loging form that was used, If I write
If IsValidatedUser(UsernameTextBox.Text, PasswordTextBox.Text) Then
frmCompanySelect.Show()
End If
| |
by: AppleBag |
last post by:
I'm having the worst time trying to login to myspace through code. Can
someone tell me how to do this? Please try it yourself before replying,
only because I have asked this a couple of times in the past in other
places, and while the help was much appreciated, it seemed everyone
just wanted to 'theoretically' explain how to do it, but when I...
|
by: Kandiman |
last post by:
Hiya, i made a asp page, and one of my divs (as a include) is as below. the problem is if the main page is resubmitted, i get logged out again?...
heres the code.. i think its on the value=true for the hidden textbox on the logout sub.. but how do i get round this? can i not change the value onclick?
<div id=Rightbody>
<!--<form...
|
by: DavidPr |
last post by:
When I logout as one user and log in under a different user, it opens with the last user's information.
User 1 - Unsername: Davey Jones
User 2 - Unsername: David Smith
I log out from Davey Jones, then login as David Smith the Welcome message below will show "Welcome Davey". And it will be Davey's information that is accessible - not David...
|
by: tvnaidu |
last post by:
This is the Java script I am using fo rlogin page, but cursor not pointing to login box, any idea how can I point cursor to login box when this page loaded?. here admin login take to control page and user login take to status page, if I give direct path without goto login, both pages display, can I add a check if user didn't login, then redirect...
|
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 the progress and I hope you guys will help me.
The code below is what I have so far. Just put two scripts in the same directory and that is! I hope...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |