473,386 Members | 1,758 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,386 software developers and data experts.

login problem

hello everybody,

I am new with access and vba. I am creating a project where i have two type of user one is 'Admin' and another is 'User'. Now when anybody try to login into database , database should look up automatically into Usertable and find the username and its user type. I have tried this following code;

Expand|Select|Wrap|Line Numbers
  1. Dim strPW As String
  2. Dim strUser As String
  3. Dim vFound As Variant
  4.  
  5. EmployeeName.SetFocus
  6. strUser = EmployeeName.Value
  7.  
  8.  vFound = DLookup("[UserName]", "Users", "[UserType] = 'Administrator'")
  9.  uFound = DLookup("[UserName]", "Users", "[UserType]= 'User' ")
  10.  
  11.  
  12.  If vFound = EmployeeName.Value Then
  13.  stDocName = "WelcomeForm"
  14. DoCmd.OpenForm stDocName, , , stLinkCriteria
  15.   End If
  16.  
  17. If uFound = EmployeeName.Value Then
  18.  stDocName = "Welcom1Form"
  19. DoCmd.OpenForm stDocName, , , stLinkCriteria
  20.  End If
  21.  
But the problem it is just locate the first record with Admin or user, even it does not check other records for right username with its usertype from User table to login correctly
please help me with this it is really urgent i have to submit in two days at my internship.
Apr 5 '07 #1
10 1662
Denburt
1,356 Expert 1GB
here was one members answer:
Expand|Select|Wrap|Line Numbers
  1. dim s as string
  2. on error resume next
  3. s = dbengine(0).users("Fred").name
  4. if err.number <> 0 then s = ""
  5. on error goto 0
  6.  
  7. if s = "" then
  8. ' user not defined.
  9. else
  10. ' user is defined.
  11. end if
  12.  
Found Here
Apr 5 '07 #2
Thank you for your Answer

But I think what i am looking for is something different let me expain again. I have user table , it has three different column. These columns are UserType, Username and Password. Now the UserType can be either Admin or User.

Now when anybody open my database they have to enter their user name and password, upon entering their username and password the database automatically check for matching username and password, once it finds the matching username and password , the database looks for usertype in the table if it usertype is Admin then open Admin form and if user type is User then open User form. Here is the code, but it does not look beyond the very first record, i would really appreciate if some one can help me, i have to submit on my internship within two days.
Dim strPW As String
Dim strUser As String
Dim vFound As Variant


EmployeeName.SetFocus

strUser = EmployeeName.Value



vFound = DLookup("[UserName]", "Users", "[UserType] = 'Administrator'")
uFound = DLookup("[UserName]", "Users", "[UserType]= 'Guest'")


If vFound = EmployeeName.Value Then
stDocName = "WelcomeForm"
DoCmd.OpenForm stDocName, , , stLinkCriteria

End If
If uFound = EmployeeName.Value Then
stDocName = "Welcom1Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria


End If
Apr 5 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
As this is an internship project I can't write the code for you. Check out the posting guidelines in the FAQ. However, there are a couple of things I can point out.

1. Be careful to declare all variables that you use. vFound is declared but uFound is not.
2. DLookup can only return a single value. You are trying to return all users of a particular UserType. Since you have the UserName then look up the UserType for that UserName and open the appropriate form based on the returned UserType. This way you will only need one DLookup statement and one variable.
3. Allow for a null return on the DLookup by using the NZ() function.
Expand|Select|Wrap|Line Numbers
  1. NZ(Dlookup(.......), "Value to return if Null")
Hope this helps.

Mary
Apr 6 '07 #4
Hello Mary,

I am still facing the same problem , i am still getting stuck with first record. Do you have any other suggestions
Apr 6 '07 #5
Rabbit
12,516 Expert Mod 8TB
Let me offer a new persepctive. You seem to want to check to see if the text inputted by the user exists in the table and then to see if they are an admin or a user.

If so, you are going about it the wrong way with DLookup, for the first part anyways. DLookup is used to return a field of a record, not to check for it's existence among a group. You may want to take a look at DCount.
Apr 6 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
Hello Mary,

I am still facing the same problem , i am still getting stuck with first record. Do you have any other suggestions
This is what I meant ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. vFound = DLookup("[UserType]", "Users", "[UserName] ='" & strUser & "'")
This will return the UserType of the current user rather than all users of a usertype.

Mary
Apr 6 '07 #7
Thank you

It is working now. I have another question regarding Access.

I have two forms. One is main form and another is subform. I have two fields in main form and subform has few other fields and also a command button to refresh it. I can refresh the field of submain with the following code
Form1.ActiveForm.Refresh();
But how can i refresh field of Mainform with the help of subform command button. Please give me some suggestions. I would really appreciate it.
Apr 6 '07 #8
i am not sure about html, i am using for VB and it is entirely different story i guess
Apr 7 '07 #9
MMcCarthy
14,534 Expert Mod 8TB
Try this ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. Forms!MainFormName.Refresh();
Apr 7 '07 #10
Hello EveryBody,

I am developing application where i have field called box no ,and when i save box no field , it goes to column of Users. Now, my problem is when i edit the box no from 30 to 20 with the help of Edit method, It makes change with only first record it finds in table. I have many dulicate records with the same boxno, i want to change it from 30 to 20 with one click of command button. Is it possible
Please help me
Apr 13 '07 #11

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

Similar topics

4
by: Sniffer-Dog | last post by:
Hi I just wondered if anyone can spot anything wrong with the following? I have now added the session_start(); as the first command in the code to all the pages needing it. When I click on a...
5
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...
1
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...
0
by: Mike | last post by:
I can not figure out what is going on here. I hope somebody can please help!!! I've got an intranet ASP3 application running on a Win2k server. This application requires a login, so the user...
1
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...
2
by: Tom Loach | last post by:
Our system administrator set up an NT server group in order to allow our users to login to our application via https to our sql server. The group appears as a User in SQL Server when you look at...
2
by: Rujuta Gandhi | last post by:
Hi All, I am facing a very crucial problem. Im developing a web application using .net studio 2005(beta). I want my Login.aspx page to be secured(https) for encrypted login information...
1
by: xcelmind | last post by:
Hello Dev. Guru, I want to at this time introduce myself. I am Stanley Ojadovwa by name. I’m a freelance and a newbie in web application development. I’m currently using ASP as my application...
4
by: RN1 | last post by:
I am working on WinXP Pro SP3, .NET 2.0 & SQL Server 2005 (Windows Authentication). When I run a ASPX page that connects to SQL Server, the following error gets generated: Login failed for user...
10
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.