Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / January 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jonesfranckandi@yahoo.fr - 27 Jan 2007 20:59 GMT
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).
Marshall Barton - 27 Jan 2007 21:50 GMT
>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
[quoted text clipped - 5 lines]
>
>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 & """")

Signature

Marsh
MVP [MS Access]

jonesfranckandi@yahoo.fr - 27 Jan 2007 23:18 GMT
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!

> jonesfrancka...@yahoo.fr wrote:
> >I have a form where I used a Dlookup. But then I keep on having an
[quoted text clipped - 13 lines]
> Marsh
> MVP [MS Access]
Marshall Barton - 28 Jan 2007 00:02 GMT
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.
Signature

Marsh
MVP [MS Access]

>Sorry I still have the same error from vb. it says exactly the
>following error"
[quoted text clipped - 97 lines]
>> DLookup("strEmpName", "tblEmployees, "strPassword=""" &
>> Forms![8]!txtPassword & """")
jonesfranckandi@yahoo.fr - 28 Jan 2007 12:44 GMT
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
[quoted text clipped - 105 lines]
> >> DLookup("strEmpName", "tblEmployees, "strPassword=""" &
> >> Forms![8]!txtPassword & """")- Hide quoted text -- Show quoted text -
Marshall Barton - 28 Jan 2007 15:53 GMT
>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.

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.