Sorry I still have the same error from vb. it says exactly the
following error"
Run-time error' 2001':
"You canceled the previous operation."
here is the code you gave me and you are rigth strPassword field in
the table is a Text field.
code:
Private Sub Form_Open(cancel As Integer)
'display username
Me.TxtMessage = DLookup("strEmpName", "tblEmployees",
"strPassword=""" & Forms![8]!txtPassword & """")
End Sub
Look at the code behind the form '8':
Option Compare Database
Private intLogonAttempts As Integer
-----------------------------------------------------------------------
-----
Private Sub Form_Open(cancel As Integer)
'On open set focus to combo box
Me.cboEmployee.SetFocus
End Sub
-----------------------------------------------------------------------
----
Private Sub cboEmployee_AfterUpdate()
'After selecting user name set focus to password field
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.", vbExclamation,
"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.", vbExclamation,
"Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this matches value
chosen in combo box
If Me.txtPassword.Value = DLookup("strEmpPassword",
"tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then
lngMyEmpID = Me.cboEmployee.Value
'Close logon form and open Loading Form
DoCmd.OpenForm "8", acNormal, , , , acHidden
DoCmd.OpenForm "frmwelcome"
Else
MsgBox "The System Could Not Log You On. Please,check Your
Password And Try Again", vbExclamation, "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 your system administrator.", vbCritical, "Restricted Access!"
DoCmd.close acForm, "8"
DoCmd.OpenForm "System Shutting Down"
End If
End Sub
Do you think you can help me again?. Thanks for your help earlier.
Your new help would be much appreciated. Anyone who also wants to join
is welcome.
thanks in advance!
I have a form where I used a Dlookup. But then I keep on having an
error message from vb saying "Previous operation cancelled.". Here is
the code could anyone tell me what is wrong with it.
Private Sub Form_Open(cancel As Integer)
Me.TxtMessage = DLookup("strEmpName", "tblEmployees", "[strPassword]="
& Forms![8]![txtPassword])
note that form '8' runs in hidden mode(clever han).If the strPassword field in the table is a Text field:
DLookup("strEmpName", "tblEmployees, "strPassword=""" &
Forms![8]!txtPassword & """")