Error Message!!!!!!!!!!

  • Thread starter Thread starter jonesfranckandi
  • Start date Start date
J

jonesfranckandi

Hi, everyone

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).
 
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 & """")
 
hi there Marshall Barton

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 & """")
 
Not sure with that error, but the open event is too soon to
assign a control's value. Try moving the code to the form's
Load event.
--
Marsh
MVP [MS Access]


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 & """")
 
Hi There Marshall Barton,

Thank for your help. In fact it was not the formula that was wrong it
was the settings of my table. I redid my form with new tables and
everything is working fine. no error messages. Thanks for your help
though!!. I appreciate that. But I do have a question. I hope you can
help me. I have a formula in vb that call a shell application. In fact
it calls a media player. Now it works fine. But I do have and exit
button on the form. I assign this code: Application.quit. That is the
code I entered to close the shell application. But Access closes
instead and the application still running. I want that when the button
is clicked the application closes not access. Do you think you can
help me?. Here take look at this code:

Private Sub PlayMovie_Click()
'check if Field is empty
Dim stAppName As String
If IsNull(Me.txtMP3) Or Me.txtMP3 = "" Then
Me.txtMP3.SetFocus
MsgBox "Please, Select a Movie or a Music File.", vbOKOnly +
vbExclamation, " Empty Field"
Exit Sub
End If
'take cases
If Me!Fr.Value = 1 And Me!Frmovie.Value = 2 Then
MsgBox "You Can't Play this File with The Selected Media." & vbCrLf &
vbCrLf & "Real Player is The Appropriate Media For This File.",
vbExclamation, "Invalid Media"
Me!Frmovie.Value = 1
Me.txtMP3 = ""
Exit Sub
End If
If Me!Fr.Value = 2 And Me!Frmovie.Value = 2 Then
MsgBox "You Can't Play this File with The Selected Media." & vbCrLf &
vbCrLf & "Real Player is The Appropriate Media For This File.",
vbExclamation, "Invalid Media"
Me!Frmovie.Value = 1
Me.txtMP3 = ""
Exit Sub
End If
If Me!Fr.Value = 3 And Me!Frmovie.Value = 1 Then
MsgBox "You Can't Play this File with The Selected Media." & vbCrLf &
vbCrLf & "Window Media Player is The Appropriate Media For This
File.", vbExclamation, "Invalid Media"
Me!Frmovie.Value = 2
Me.txtMP3 = ""
Exit Sub
End If
If Me!Fr.Value = 4 And Me!Frmovie.Value = 1 Then
MsgBox "You Can't Play this File with The Selected Media." & vbCrLf &
vbCrLf & "Window Media Player is The Appropriate Media For This
File.", vbExclamation, "Invalid Media"
Me!Frmovie.Value = 2
Me.txtMP3 = ""
Exit Sub
End If
'start playing movie

If Me!Frmovie.Value = 1 Then
stAppName = "C:\Program Files\Real\RealPlayer\realplay.exe "
Call Shell(stAppName, 1)
Application.FollowHyperlink Me.txtMP3
Me.txtMP3 = ""
Else
If Me!Frmovie.Value = 2 Then
stAppName = "C:\Program Files\Windows Media Player\wmplayer.exe"
Call Shell(stAppName, 1)
Application.FollowHyperlink Me.txtMP3
Me.txtMP3 = ""
Else
Exit Sub
End If
End If

End Sub
-------------------------------------------------------------------
Private Sub Close_Click()

Me.txtMP3 = ""
DoCmd.close acForm, "Media", acSaveYes
Application.quit
End Sub

My concern is the last bit for Close_click. I which it to close or
exit application as soon as the user click on it.Note that this is
only the first bit of my code behind the form. I have an another code
that let the user select a file movie or music to play.

Your help would be the most welcome. If anyone has any suggestions he
can jump in as well.
Thanks in adavnce!!!!!

Not sure with that error, but the open event is too soon to
assign a control's value.  Try moving the code to the form's
Load event.
--
Marsh
MVP [MS Access]



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
   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,checkYour
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
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!
(e-mail address removed) wrote:
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 strPasswordfield in the table is a Text field:
DLookup("strEmpName", "tblEmployees, "strPassword=""" &
Forms![8]!txtPassword & """")- Hide quoted text -- Show quoted text -
 
Thank for your help. In fact it was not the formula that was wrong it
was the settings of my table. I redid my form with new tables and
everything is working fine. no error messages. Thanks for your help
though!!. I appreciate that. But I do have a question. I hope you can
help me.
[ . . . ]

I still say that code should be in the load event.

You should start a new thread with your new question. Other
folks that might know something about the different topic
will then have a chance to get involved.
 
Back
Top