I am creating simple login form with linked tables(atual tables are in SQL 2005) in access 2003.
Here is my code. - Option Compare Database
-
-
-
Private Sub cmdSignIn_Click()
-
'Check to see if data is entered into the UserName combo box
-
-
If IsNull(Me.txtUsername) Or Me.txtUsername = "" Then
-
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
-
Me.txtUsername.SetFocus
-
Exit Sub
-
End If
-
-
'Check to see if data is entered into the password box
-
-
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
-
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
-
Me.txtPassword.SetFocus
-
Exit Sub
-
End If
-
-
'Check value of password in tbl_ValUsers to see if this
-
'matches value chosen in combo box
-
- If Me.txtPassword.Value = DLookup("Password", "RadioLog_tblValUsers", "[UserName] = " _
-
& Me.txtUsername.Value) Then
-
-
UserName = Me.txtUsername.Value
-
-
'Close logon form and open splash screen
-
-
DoCmd.Close acForm, "frmLogin", acSaveNo
-
DoCmd.OpenForm "Switchboard"
-
-
Else
-
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
-
"Invalid Entry!"
-
Me.txtPassword.SetFocus
-
End If
-
-
'If User Enters incorrect password 3 times database will shutdown
-
-
intLogonAttempts = intLogonAttempts + 1
-
If intLogonAttempts > 3 Then
-
MsgBox "You do not have access to this database.Please contact admin.", _
-
vbCritical, "Restricted Access!"
-
Application.Quit
-
End If
-
-
End Sub
-
-
Private Sub txtUsername_AfterUpdate()
-
Me.txtPassword.SetFocus
-
End Sub
I am getting this run time error 2001 when I click on "Sign In" after entering Username and password. When I click on debug it takes me to the line in bold.
Any clue what is going on?
Assuming the UserName field contains a string, you need to delimit it with quotes. - ..., "UserName = '" & txtUserName & "'") Then
3 4669
Assuming the UserName field contains a string, you need to delimit it with quotes. - ..., "UserName = '" & txtUserName & "'") Then
One has to presume that txtUsername is Text, but your syntax - If Me.txtPassword.Value = DLookup("Password", "RadioLog_tblValUsers", "[UserName] = " & Me.txtUsername.Value) Then
is only correct for a Numeric Datatype. For Text it would be : - If Me.txtPassword.Value = DLookup("Password", "RadioLog_tblValUsers", "[UserName] = '" & Me.txtUsername.Value & "'") Then
Linq ;0)>
Thanks that worked.!!
One more situation: how do we specify the criteria if we are matching the username that is on another form's textbox?
Something like this
If Me.txtSecurityCode.Value = DLookup("[SecurityCode]", "RadioLog_tblValUsers", "[UserName] =" & Forms!frmLogin!txtUsername) Then
Is this correct?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: RWC |
last post by:
Hi,
I'm running into a problem with Access XP (SP2) that's driving me up the
wall. It's Error 2001 "You canceled the previous operation". There is no
voodoo going on really when I get this...
|
by: John A. |
last post by:
This is a database in use on Terminal server, been reliable, no corruption
problems. (so far)
Designing a form, asked to save objects, Access put up a dialog box for the
current form asking me...
|
by: Crayola465 |
last post by:
I have been trying to figure this out for a couple weeks and after reading every post in the forum about the subject I have not found anything that works.
I have two tables;
1) has company...
|
by: Widge |
last post by:
I've been using code similar to this:
Option Compare Database
Private Sub Form_Open(Cancel As Integer)
SetFilter
|
by: pukhton |
last post by:
I am getting a yellowish block on Refresh statement under Medication_Name_AfterUpdate, and If i take it out it comes to the End sub... dont know what is goign on?
This is what I have under Text52...
|
by: noneedforthis |
last post by:
I'm a new user of Access/VB and ran in to this nasty wall.
(Access 2003, VB6.3, Windows XP)
Runtime Error 2001: You cancelled the previous operation.
The highlighted line is the one where the...
|
by: David01 |
last post by:
When I run some code behind a button i get a runtime error message. The strange thing is that the code run perfectly some months ago. Can some one help me !
Some additional information: The company...
|
by: jmoudy77 |
last post by:
I've got some vb code that gives me a "previous operation cancelled" error when I try and open the form as a subform in a tabbed control. When I open the form itself I don't get the error. Does...
|
by: Heather M |
last post by:
I am receiving a Run-time 2001 You canceled the previous operation.
I have a form which has unbound boxes where you select the date and set a role. The query runs for one role for every month. ...
|
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...
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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: 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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |