473,566 Members | 3,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Login Form

145 New Member
** 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
Expand|Select|Wrap|Line Numbers
  1. lngID,PK,Autonumber
  2. UserName,Text
  3. IsAdmin,Text
  4. Password,Text
  5.  
and a form name [frmLogin] with the following
Expand|Select|Wrap|Line Numbers
  1. cmbUserName,ComboBox
  2. txtPassword,TextBox
  3. btnLogin,Button
  4.  
I already insert this code
Expand|Select|Wrap|Line Numbers
  1. Private Sub btnLogin_Click()
  2.  
  3.     If IsNull(Me.cmbUserName) Or Me.cmbUserName = "" Then
  4.         MsgBox "Please enter UserName", vbOKOnly, "Required"
  5.         Me.cmbUserName.SetFocus
  6.         Exit Sub
  7.     End If
  8.  
  9.     If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
  10.         MsgBox "Please enter Password", vbOKOnly, "Required"
  11.         Me.txtPassword.SetFocus
  12.         Exit Sub
  13.     End If
  14.  
  15.     If Me.txtPassword.Value = DLookup("Password", "UserConfig", "[lngID]=" & Me.cmbUserName.Value) Then
  16.         lngID = Me.cmbUserName.Value
  17.  
  18.     Else
  19.         MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry"
  20.         Me.txtPassword.SetFocus
  21.     End If
  22.  
  23.     Exit Sub
  24.  
  25.     intLogonAttempts = intLogonAttempts + 1
  26.     If intLogonAttempts > 3 Then
  27.         MsgBox "You do no have access to this database.", vbCritical, "Restricted Access!"
  28.         Application.Quit
  29.     End If
  30.  
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
Expand|Select|Wrap|Line Numbers
  1. If DLookup("IsAdmin", "UserConfig", "[lngID]=" & Me.cmbUserName.Value = "Yes") Then
  2.         ...'Coding for allowing access to application/form(I do not know)
  3.     Else
  4.  
  5.     If DLookup("IsAdmin", "UserConfig", "[lngID]=" & Me.cmbUserName.Value = "No") Then
  6.         ...'Coding for allowing access to application/form(I do not know)
  7.     End If
  8.  
  9.     DoCmd.OpenForm "MAIN MENU"
  10.     DoCmd.Close acForm, "frmLogin", acSaveNo
  11.  
...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
Expand|Select|Wrap|Line Numbers
  1.  If DLookup("IsAdmin", "UserConfig", "[lngID]=" & Me.cmbUserName.Value = "Yes") Then
  2.         MsgBox "You are a Administrator", vbOKOnly
  3.     Else
  4.  
  5.     If DLookup("IsAdmin", "UserConfig", "[lngID]=" & Me.cmbUserName.Value = "No") Then
  6.         MsgBox "You are a User", vbOKOnly
  7.         Exit Sub
  8.     End If
  9.  
  10.     DoCmd.OpenForm "MAIN MENU"
  11.     DoCmd.Close acForm, "frmLogin", acSaveNo
  12.  
but when click the button nothing happen...

Sorry for asking this question again....
Sep 25 '08 #1
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 :
Expand|Select|Wrap|Line Numbers
  1. If IsNull(Me.cmbUserName) Then
  2.     MsgBox "Please enter UserName", vbOKOnly, "Required"
  3.     Me.cmbUserName.SetFocus
  4.     Exit Sub
  5. End If
Sep 25 '08 #2
NeoPa
32,564 Recognized Expert Moderator MVP
After line #13 you need to add in :
Expand|Select|Wrap|Line Numbers
  1. intLogonAttempts = 0
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.
Sep 25 '08 #3
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.
Sep 25 '08 #4
puT3
145 New Member
This the code after few changes,not much...
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Command6_Click()
  4.  
  5.     Dim intLogonAttempts As Integer
  6.  
  7.     If IsNull(Me.cmbUserName) Or Me.cmbUserName = "" Then
  8.         MsgBox "Please enter UserName", vbOKOnly, "Required"
  9.         Me.cmbUserName.SetFocus
  10.     Exit Sub
  11.     End If
  12.  
  13.     If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
  14.         MsgBox "Please enter Password", vbOKOnly, "Required"
  15.         Me.txtPassword.SetFocus
  16.     Exit Sub
  17.     End If
  18.  
  19.     If Me.txtPassword.Value = DLookup("Password", "UserConfig", "[lngID]=" & Me.cmbUserName.Value) Then
  20.         lngID = Me.cmbUserName.Value
  21.         intLogonAttempts = 0
  22.     Else
  23.         MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry"
  24.         Me.txtPassword.SetFocus
  25.     End If
  26.     Exit Sub
  27.  
  28.     intLogonAttempts = intLogonAttempts + 1
  29.     If intLogonAttempts > 3 Then
  30.         MsgBox "You do no have access to this database.", vbCritical, "Restricted Access!"
  31.         Application.Quit
  32.     End If
  33.  
  34.     End Sub
  35.  
Sep 26 '08 #5
puT3
145 New Member
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...
Sep 26 '08 #6
NeoPa
32,564 Recognized Expert Moderator MVP
From your psted code I would make the following comments :
  1. Add the line "Option Explicit" after "Option Compare Database".
  2. Set this as the default (From VBA Editor select Tools / Options / Editor Tab / Require Variable Declaration).
  3. Compile your code (always) before posting it. This avoids confusion as we expect any posted code to be compiled unless otherwise stated.
  4. 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.
  5. 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).
    1. Declare it as Private in the module OUTSIDE of any procedures (preferably before any of your code).
    2. 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.
Sep 26 '08 #7
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?
Sep 26 '08 #8

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

Similar topics

5
2959
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...
1
2136
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...
1
5461
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...
3
2342
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 /...
3
3865
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
6
3334
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...
1
3317
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...
10
4799
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...
21
3839
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...
13
4157
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...
0
7683
marktang
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...
0
7899
Oralloy
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. ...
0
8113
jinu1996
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...
0
6270
agi2029
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...
1
5487
isladogs
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...
0
3628
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2092
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
1
1204
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
927
bsmnconsultancy
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...

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.