473,396 Members | 2,109 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,396 software developers and data experts.

Login Form with Multi user login

Hi I have this project currently on going and I'm stack in the login form, I've done most of the part but still i cant seem to find a solution to this part.

the login form has 2 Textbox and 1 Combobox (usernameTB, passwordTB, userTypeCB) im finish with the part of comparing the username and the password whether the two match in my table, but what i cant seem to do is compare whether the user type(Administrator, Standard User) match the datas in the table.

HERE is my code so far and whenever I try to login using this codes it keeps on telling me "Run-time error '2471': The expression you entered as a query parameter produced this error: 'Administrator' (TAKE NOTE that the value's in the userTypeCB are "Administrator" and "Standard User"

one last thing, this isnt the complete code because this is a copy my project that im working on, i made a diff. copy so that i could do whatever i want without the harm of totally ruining the whole project. Any help would be appreciated. Thanks!

Expand|Select|Wrap|Line Numbers
  1. Private Sub signinBTN_Click()
  2.  
  3. Dim adminType As String
  4. Dim userType As String
  5.  
  6. If IsNull(Me.usernameTB) Then
  7.     MsgBox "Please enter a username", vbInformation, "Need Username!"
  8.         Me.usernameTB.SetFocus
  9.     Exit Sub
  10. End If
  11.  
  12. If IsNull(Me.passwordTB) Then
  13.     MsgBox "Please enter a password!", vbInformation, "Need Password!"
  14.         Me.passwordTB.SetFocus
  15.     Exit Sub
  16. End If
  17.  
  18.  
  19. If Nz(DLookup("Password", "UserINFO", "Username = '" & Me.usernameTB & "'"), "GarbageEntry") = Me.passwordTB Then
  20.  
  21.     MsgBox "User Found!", vbOKOnly
  22.  
  23.     If Me.passwordTB.Value = DLookup("Password", "userINFO", "ID =" & Me.userTypeCB.Value) Then
  24.  
  25.     ID = Me.userTypeCB.Value
  26.  
  27.     MsgBox "password and user type match!"
  28.  
  29.     Else
  30.  
  31.     MsgBox "they dont match!"
  32.  
  33.     End If
  34.  
  35. Else
  36.     MsgBox "Incorrect Username or Password"
  37.  
  38.         Me.usernameTB = ""
  39.         Me.passwordTB = ""
  40.         Me.usernameTB.SetFocus
  41.  
  42. End If
  43. End Sub
Jun 24 '15 #1
5 3953
No need to answer my question, I've already solved it, the problem is with my data field "User Type" it seems Access VBA wont allow any space in the Dlookup method. Tried to remove the "space" in the data field and it worked. :)
Jun 24 '15 #2
zmbd
5,501 Expert Mod 4TB
Certainly Dlookup will allow this, you have to properly format the string.

It also appears that you also did not include the section of the code that has that Dlookup...
Jun 24 '15 #3
NeoPa
32,556 Expert Mod 16PB
If you have a reference that includes a space in it, which is never a good idea, then you can put square brackets ([]) around the string value to get it to be recognised almost anywhere in Access, and most other databases too.
Jun 25 '15 #4
Expand|Select|Wrap|Line Numbers
  1. If Nz(DLookup("UserType", "userINFO", "Username = '" & Me.usernameTB & "'"), "GarbageEntry") = Me.userTypeCB Then
this is the line that has space on it, it should be in line 24, forgot to add it. The one that has the space is the data field "UserType" it used to be "User Type", dunno why it worked when i removed the space in between, but im happy now that it did.
Jun 25 '15 #5
Thank you for that tip NeoPa, ill always remember it.
Jun 25 '15 #6

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

Similar topics

2
by: pv | last post by:
Hi everyone, I need help with following scenario, please: Users are accessing same web server from intranet (users previously authenticated in Active Dir) and from extranet (common public...
3
by: freee8896 | last post by:
Can nyone help me with this multi user login from the same system. Multiple users must be able to login from the same system at a time.... in PHP. Sessions must be used. Please donot suggest these...
5
by: raaman rai | last post by:
Pls give me the skeleton code in PHP as to how to redirect to the same login form after an invalid login. i have a login form and it is processed by another file when submitted. so now if the login...
0
by: sandari | last post by:
The following code (web.config in Visual Studio 2005) is supposed to redirect a user to the appropriate Form depending on their role. However, regardless of the user's role, the only page...
11
Stang02GT
by: Stang02GT | last post by:
I am in the process of creating a database for a "Team" here at work. One thing that needs to be incorporated with this database is each user will have a log in and password I know how to do that. ...
3
by: Bob Smith | last post by:
I have to come up with a user authenication page the logs the user in and also gives them access to do the right things. without using server side scripting. Just javacript and access. I have...
5
by: anewuser | last post by:
I currently have a working multi user login form in access 2007. It automatically redirects people who login to a user specific form e.g. user = staff1 is moved to form staff1 and manager1 is...
55
by: anewuser | last post by:
Hi, I currently have a working multi user login form which automatically directs users to the relevent forms e.g. general staff have access to a form called staff1 and staff2 whereas managers have...
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:
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.