I use the following code to manage user logon success: - Private Sub cmdOk_Click()
-
On Error GoTo Err_cmdOk_Click
-
'-----------------------------------------------------------------------------------------------------------------------------
-
' This code is used to validate users found in the tblSecurity table. If the wrong user name or password is
-
' provided access is denied.
-
'-----------------------------------------------------------------------------------------------------------------------------
-
Dim db As DAO.Database
-
Dim rst As DAO.Recordset
-
Dim rstV As Recordset
-
Dim stDocName As String
-
Dim stLinkCriteria As String
-
-
Set db = CurrentDb()
-
Set rst = db.OpenRecordset("tblSecurity", dbOpenDynaset)
-
-
If Not IsNull(Me.txtUser) And Not IsNull(Me.txtPassword) Then
-
rst.FindFirst "Password = '" & Me.txtPassword & "'" & " And UserID = '" & Me.txtUser & "'"
-
-
If rst.NoMatch Then
-
MsgBox "You entered the wrong User Name or Password." & Chr(13) & _
-
"Please enter the correct User Name and Password or " & Chr(13) & _
-
"contact the Database Adminstrator for assistance.", vbOKOnly + vbCritical, "Logon Denied"
-
ElseIf Me.txtPassword = "password" Then
-
MsgBox "This is the first time using the database or your passowrd has been reset." & Chr(13) & _
-
"You must change your password before you can enter the database.", _
-
vbOKOnly + vbExclamation, "Change Password"
-
stDocName = "frmUserLogonNew"
-
stLinkCriteria = "[UserID]=" & "'" & Me![txtUser] & "'"
-
DoCmd.OpenForm stDocName, , , stLinkCriteria
-
Else
-
stDocName = "frmSplashScreen"
-
DoCmd.OpenForm stDocName, , , stLinkCriteria
-
End If
-
Else
-
MsgBox "You left the User Name and/or Password blank." & Chr(13) & _
-
"Please enter the correct User Name and Password or " & Chr(13) & _
-
"contact the Database Adminstrator for assistance.", vbOKOnly + vbCritical, "Logon Denied"
-
End If
-
-
-
With Forms!frmhidden
-
.txtViewID = rst.Fields("ViewID")
-
.txtAccessID = rst.Fields("AccessID")
-
.txtActive = rst.Fields("Active")
-
.txtPassword = rst.Fields("Password")
-
.txtUserID = rst.Fields("UserID")
-
.txtSecurityID = rst.Fields("SecurityID")
-
.txtFName = rst.Fields("FName")
-
.txtSName = rst.Fields("SName")
-
.txtEMailAd = rst.Fields("EmailAd")
-
.txtUdept = rst.Fields("UDept")
-
End With
-
-
-
rst.Close
-
-
Exit_cmdOk_Click:
-
Exit Sub
-
-
Err_cmdOk_Click:
-
MsgBox err.Description
-
Resume Exit_cmdOk_Click
-
-
End Sub
On the same form where that code resides there is a cancel button with the following code: - Private Sub cmdCancel_Click()
-
On Error GoTo Err_cmdCancel_Click
-
-
Dim intResponse As Integer
-
-
Forms!frmUserLogon.Visible = False
-
-
intResponse = MsgBox("Warning: By canceling, you are about to completely exit the database." & Chr(13) & _
-
"Are you sure you want to do this?", vbYesNo + vbExclamation, "Exiting Database")
-
-
Select Case intResponse
-
Case vbYes
-
-
DoCmd.Quit
-
Case Else
-
Forms!frmUserLogon.Visible = True
-
End Select
-
-
Exit_cmdCancel_Click:
-
Exit Sub
-
-
Err_cmdCancel_Click:
-
MsgBox err.Description
-
Resume Exit_cmdCancel_Click
-
-
End Sub
The behaviour that is strange is that if no user information is present and I click cancel, the database closes as it should.
However, If I enter valid user information within the username/password text boxes and click cancel... I get logged in.
Can anyone explain why this is happening? I cant for the life of me see how the Login and Cancel button can be linked here =|
Regards,
Chris
0 1245 Sign in to post your reply or Sign up for a free account.
Similar topics
by: MB |
last post by:
Hi,
I am doing a project which uses asp.net to develop its forms. The form
uses validation web controls to validate the data entered in text
boxes. When Cancel Button is pressed which is to exit...
|
by: clintonG |
last post by:
This is an appeal for peer support sent to Microsoft as will be noted in
closing.
The Login control does not include a Cancel button.
The only option is to convert the Login control to a...
|
by: holysmokes99 |
last post by:
I am trying to implement a cancel button on my application that ingests
a bunch of data from a text file into a database. I have not worked too
much with threads, so I am having some trouble. I had...
|
by: Stuart Whiteford |
last post by:
Hi,
I've got a basic web form, two textboxes, a couple of radio button groups,
some required field validators, and a Submit and Cancel button.
When the page loads, if I click the Cancel...
|
by: Matthew |
last post by:
I have a popup "Property" form that I want to be used as a dialog box.
I want the user to be able to cancel their addition of the property
wtihout closing the form. .Net however automatically...
|
by: Darin |
last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to
handle textbox.validating, and I have the form setup so the Cancel
button is the Cancel button.
WHen the user clicks on...
|
by: Sergey Zuyev |
last post by:
Hello all
I have simple edit form. When user saves data that contains restricted
characters such as (< , etc.) , regular expression validator will display
a warning message. It all works fine,...
|
by: martin |
last post by:
Hello,
Is there a way to make a kind of "cancel" button on a form?
Suppose you accidently changed or overwrote some data in a form, then I'd
like to leave this form at once and cancel any...
|
by: MaxMax |
last post by:
I have a dialog box with a Cancel button that I want to be activable with
the ESC key. In the form the Cancel button is connected to the CancelButton
property. Now my problem is that the OnClick...
|
by: ghjk |
last post by:
I have "cancel" button in php files. I want to write common javascript function for cancel button. When user click cancel button I want to clear php form data.
Is it possible?
<input id="Cancel"...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
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: 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: 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...
| |