Hi, actually I'm creating a database for some coursework at school. It's basically about a booking system and how I book hardware in and out of the school for students who need the hardware. I've tried to create a login screen, so that teachers can log in and out the system. I've got one table that is involved in this code, which is the 'tblTechnicianFile'. That's the table that contains the technician's ID and the password as well. The following links are print screens of my tblTechnicianFile and my actual form, which is my login screen.
http://i209.photobucket.com/albums/bb68/ud1992/ms%20access%20prob/Untitled-2.png
http://i209.photobucket.com/albums/bb68/ud1992/ms%20access%20prob/Untitled-4.png
The problem is that it is supposed to send me to another screen when the password is right, but it keeps giving me the "run-time error..." screen whether I put in the right password or not.
This is the all the codes that I have got entered, something must be wrong with it, but I cannot spot it. Help.
Option Compare Database
Private Sub cboEmployee_AfterUpdate()
Me.txtPassword.SetFocus
End Sub
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.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 login to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("Password", "tblTechnicianFile", _
"[Technician ID]=" & Me.cboEmployee.Value) Then
lngMyEmpID = Me.cboEmployee.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "login screen", 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
---------------------------------------------------------------------------------------------------------------
Additional Details
if anyone wants to contact me to get more details about this problem or anything like that, my msn is: uddeshd@yahoo.co.uk
Hi
OK so you have a text user ID (Why?), then I suggest changing this - If Me.txtPassword.Value = DLookup("Password", "tblTechnicianFile", _
-
"[Technician ID]=" & Me.cboEmployee.Value) Then
to this - If Me.txtPassword.Value = DLookup("Password", "tblTechnicianFile", _
-
"[Technician ID]='" & Me.cboEmployee.Value & "'") Then
Note th apostrophies enclosing Me.cboEmployee.Value
These delimiters are required for all text variable in this situation so the program knows where the variable text starts and ends within the program text.
HTH
MTB
5 4709
Hi
Just one suggestion:-
Try opening the 'Switchboard' BEFORE you close the 'Login Screen'
??
MTB
erm, I'm not really sure what you mean by that.. are you telling me to edit the code, or open the switchboard form?
If you mean edit the code, can you give me the new code please, as I am not really good with coding.
I found those coding instructions on how to make a login form from this website: http://www.databasedev.co.uk/login.html
but apparently that code only works if the ID is an autonumber field, and mine is a text one. That's what is causing the problem, as it worked fine for my friend, because he had his TechnicianID field as an autonumber.
Thanks.
Hi
OK so you have a text user ID (Why?), then I suggest changing this - If Me.txtPassword.Value = DLookup("Password", "tblTechnicianFile", _
-
"[Technician ID]=" & Me.cboEmployee.Value) Then
to this - If Me.txtPassword.Value = DLookup("Password", "tblTechnicianFile", _
-
"[Technician ID]='" & Me.cboEmployee.Value & "'") Then
Note th apostrophies enclosing Me.cboEmployee.Value
These delimiters are required for all text variable in this situation so the program knows where the variable text starts and ends within the program text.
HTH
MTB
thanks a lot mate, it worked. However, now the problem is with the last code
'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
This is the code that checks if an incorrect password has been entered more than 3 times.. I tried entering a wrong password over 3 times, but didn't work, would apreciate if you could help me on this bit as well? Thanks again.
Hi
Two things
1) You do not say what actually happens
2) Where is the variable 'intLogonAttempts' declared?
To start I would temperarily add this line
MsgBox intLogonAttempts
immediatly after this line
intLogonAttempts = intLogonAttempts + 1
and see if it starts at 1 and index with each incorrct password.
'intLogonAttempts' should be declared at the top of the form 'login screen' code module ie.
Dim intLogonAttempts as Integer
MTB
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Vilmar Brazão de Oliveira |
last post by:
Hi all,
I was using:
<% Set objWshell = Server.CreateObject("WScript.Shell")
objWshell.Run "%COMSPEC% /C ren topoX.jpg topo_cliente.jpg", 0, TRUE %>
BUT the comand COMSPEC disapeared of all my...
|
by: Jenna Olson |
last post by:
Hi all-
I've never seen this particular issue addressed, but was wondering if
there's anything to support one way or another. Say I have a class:
class ManipulateData
{
public:...
|
by: Curious Angel |
last post by:
I have a resume in PDF format and I want anyone who LEFT-OR-RIGHT clicks the link to
force the file to be saved, and in any event _not_ opened.
Since the PDF will be in his cache in any event, I...
|
by: dice |
last post by:
I have built a .NET based service that uses a number of related 3rd party dlls.
If I compile my code into a dll and use this in a test app all is well -
however if I compile my code as a service...
|
by: PASQUALE |
last post by:
Hi,
I am new to DB2 on AS/400. Actually I use the 'Run SQL Scripts' - tool in
iSeries Navigator to access the database by SQL.
The question is: Is there an alternative (or maybe better) tool for...
|
by: n_o_s_p_a__m |
last post by:
Can't compile. Does this mean that all functions that throw exceptions
must be of return type void?
examples:
// won't compile: "not all code paths return a value"
public override int Run() {...
|
by: Raúl Martín |
last post by:
I´ve a function in asp that run correctly but If I tried to change it
forasp.net
in asp:
xmlHTTP = CreateObject("Microsoft.XMLHTTP")
And I thought to use this sentence for asp.net but the...
|
by: Matt |
last post by:
Hi All,
Is it possible to display the progress of a query in the bottom left
of the database application, but instead of having the text say "Run
Query", have it say some text that I determine.
|
by: Anna |
last post by:
I try to put 8 int bit for example 10100010 into one character of type
char(1 octet) with no hope . Could anyone propose a simple way to do
it? Thank you very much.
|
by: Scott Gravenhorst |
last post by:
Windows XP SP3
My application is set to open a SaveFile dialog when an exit is
requested. When I click the app's close button, the save dialog
opens, but when I click to change the folder, the...
|
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
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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...
|
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: 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: 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...
| | |