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

Login Form

Slaxer13
106 64KB
Hi ppl. I am having trouble with a login form. When i click the btnConfirmar, after having both Login and Password it gives me an error 2471: The expression you entered as a query parameter produced this error: the error is whatever value is in the cboLogin.
Anyone has an ideia of what the solution might be?
As an attachment there is a pic of the form.
Any help would be great, Slaxer13.

Expand|Select|Wrap|Line Numbers
  1. Public UtzID As Long
  2.  
  3. Private Sub btnConfirmar_Click()
  4.  
  5.     'Confere se foi escolhido um Login
  6.  
  7.     If IsNull(Me.cboLogin) Or Me.cboLogin = "" Then
  8.       MsgBox "Tem de escolher um LOGIN", vbOKOnly, "Campo Obrigatório"
  9.         Me.cboLogin.SetFocus
  10.         Exit Sub
  11.     End If
  12.  
  13.     'Confere se a password foi introduzida
  14.  
  15.     If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
  16.       MsgBox "Tem de inserir PASSWORD", vbOKOnly, "Campo Obrigatório"
  17.         Me.txtPassword.SetFocus
  18.         Exit Sub
  19.     End If
  20.  
  21.     'Confere se a password é igual ao do login na tblUtilizador
  22.  
  23.     If Me.txtPassword.Value = DLookup("Password", "tblUtilizador", "[Cod_Utilizador]=" & Me.cboLogin.Value) Then
  24.  
  25.         UtzID = Me.cboLogin.Value
  26.  
  27.         'Fecha o frmLogin e abre o programa
  28.  
  29.         DoCmd.Close acForm, "frmLogin", acSaveNo
  30.         DoCmd.OpenForm "frmUtente"
  31.  
  32.     Else
  33.       MsgBox "Password Errada! Tente Outra Vez", vbOKOnly, _
  34.             "Password Errada"
  35.         Me.txtPassword.SetFocus
  36.     End If
  37.  
  38.     'Se o utilizador escrever a password mal três vezes a base de dados é fechada
  39.  
  40.     intLogonAttempts = intLogonAttempts + 1
  41.     If intLogonAttempts > 3 Then
  42.       MsgBox "Não tem acesso á basa de dados. Contacte o Administrador.", _
  43.                vbCritical, "Acesso Restrito!"
  44.         Application.Quit
  45.     End If
  46.  
  47. End Sub
  48.  
  49. Private Sub cboLogin_AfterUpdate()
  50.  
  51.     Me.txtPassword.SetFocus
  52.  
  53. End Sub
Attached Images
File Type: jpg Sem Título.jpg (11.6 KB, 110 views)
Jun 26 '14 #1
5 1111
twinnyfo
3,653 Expert Mod 2GB
Slaxer,

upon which line of code is the error generating itself?
Jun 26 '14 #2
jimatqsi
1,271 Expert 1GB
You probably misspelled the field name used in the criteria for the Dlookup. Check the spelling of this field:[Cod_Utilizador]

Jim
Jun 26 '14 #3
twinnyfo
3,653 Expert Mod 2GB
Is the value of your cboLogin a text value or integer?

If it is a text value then, line 23 should be:

Expand|Select|Wrap|Line Numbers
  1. If Me.txtPassword.Value = DLookup("Password", "tblUtilizador", _
  2.     "[Cod_Utilizador] = '" & Me.cboLogin & "'") Then
I hope this helps!
Jun 26 '14 #4
Slaxer13
106 64KB
Thanks for the reply. I found the problem.

Expand|Select|Wrap|Line Numbers
  1.  If Me.txtPassword.Value = DLookup("[Password]", "tblUtilizador", "[Login]='" & Me.cboLogin.Value & "'") Then
The code should be this way (the changes are bold and italic). My bad. But thanks anyway ;)
Cheers, Slaxer13
Jun 26 '14 #5
twinnyfo
3,653 Expert Mod 2GB
I see brilliant minds think alike! Glad we could help!
Jun 26 '14 #6

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

Similar topics

1
by: John Wolrehammer | last post by:
After the user login in i want to close the login form. I can close it but it also closes the whole application. Can anyone help.
5
by: JPSutor | last post by:
I have a login form, that if successfully answered, launches another form. The problem is that the login form remains even after I show the main form. How do I get rid of the login form?
4
by: David Krussow | last post by:
Just wondering if/how it would be possible to display a variable string on the login form - where the string varies depending on the form the user attempted to access. To clarify, an...
3
by: Agnes | last post by:
My login form will call a main form with menu in my button_OK click event >dim frmMain as new mainform >frmMain.show() >Me.dispose() The login form didn't close by itself, Please help.. Thanks
3
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...
5
by: Ronald S. Cook | last post by:
It's been longer that I remember since writing windows (not web) apps. 1) I want to load a main form 2) User clicks login button which brings up login form (on top of main form) 3) Upon...
13
by: knot2afrayed | last post by:
I am trying to fix error- object does not exist- I want it possible to allow object not to exist. I am writing a script on a page that may or may not include a login form. For example-after a...
1
by: naharol | last post by:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@page import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01...
3
matheussousuke
by: matheussousuke | last post by:
I dont get any error message, it's simple, some pages works ok, they simply show "Welcome, 'username'. LOGOUT (link)" The same as Bytes, when u login, u dont see the form anymore, u just see a...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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.