Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[B]There was an error executing the command.[/B]

Status
Not open for further replies.

Nidhal

IS-IT--Management
Dec 16, 2004
12
US

Is this where I should post this question?

I have a database that is being used by multiple users. Each user has an MDE file on their PC and the data is stored/referenced in a separate mdb on a network shared drive. When someone is using the program concurrently and a second user tries to open forms, etc. I always receive the following error message:

"There was an error executing the command."

I have set the Default Open Mode to "Shared" and the
Default Record Locking mode to "No Lock"

Any help would be appreciated. Thanks.
 
What if any code is in the form's On Open, On Load or On Activate events?

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Do all of them have permission granted to access the network folder(not *.mdb)?

Zameer Abdulla
Visit Me
 
Yes, the permision to access the network folder is set to Everyone with full read-write access.
 
That's all I have.

Private Sub Form_Open(Cancel As Integer)
' Minimize the database window and initialize the form.

' Move to the switchboard page that is marked as the default.
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.FilterOn = True

End Sub
 
Is your Switchboard form having a recordsource?
If this code you are applying only to bring the form appear first then, remove it.
From the tools menu
Tools > Startup > Display Form/Page select the FormName there.
Or tell us what you are doing with this code. Or Comment Out the code and test the DB.

Zameer Abdulla
Visit Me
 
Not using recordsource property.
I removed the form from loading at start up by going to Tools > Startup > Display Form/Page and tested the DB. Still the same error. I am merely using the code to display the switchboard form. It is generated code. I did not modify it.
 
If anyone can help me it would be most appreciated. I've had the this error for a month now and have tried just about everything...
 
Is the error a pop up or does it have a message box with a debug button pointing to code?

What happens after you acknowledge the message?

Is this the only thing the message says?

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
The dialog box only pops up when you try to navigate through the switchboard to other forms while another user is using a form to enter data. The dialog does not have a debug button. The dialog shows the error msg that has an OK button. After the message is acknowledged it returns to the switchboard. Where you first begin when the database is opened.
 
One more question if you go to the design mode of the switchboard and go to the On Click event of the button to go to another form, cut and paste the entire code that is in that event into here.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Private Function HandleButtonClick(intBtn As Integer)
' This function is called when a button is clicked.
' intBtn indicates which button was clicked.

' Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8
Const conCmdOpenPage = 9

' An error that is special cased.
Const conErrDoCmdCancelled = 2501

Dim con As Object
Dim rs As Object
Dim stSql As String

On Error GoTo HandleButtonClick_Err

' Find the item in the Switchboard Items table
' that corresponds to the button that was clicked.
Set con = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.Recordset")
stSql = "SELECT * FROM [Switchboard Items] "
stSql = stSql & "WHERE [SwitchboardID]=" & Me![SwitchboardID] & " AND [ItemNumber]=" & intBtn
rs.Open stSql, con, 1 ' 1 = adOpenKeyset

' If no item matches, report the error and exit the function.
If (rs.EOF) Then
MsgBox "There was an error reading the Switchboard Items table."
rs.Close
Set rs = Nothing
Set con = Nothing
Exit Function
End If

Select Case rs![Command]

' Go to another switchboard.
Case conCmdGotoSwitchboard
Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rs![Argument]

' Open a form in Add mode.
Case conCmdOpenFormAdd
DoCmd.OpenForm rs![Argument], , , , acAdd

' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument]

' Open a report.
Case conCmdOpenReport
DoCmd.OpenReport rs![Argument], acPreview

' Customize the Switchboard.
Case conCmdCustomizeSwitchboard
' Handle the case where the Switchboard Manager
' is not installed (e.g. Minimal Install).
On Error Resume Next
Application.Run "ACWZMAIN.sbm_Entry"
If (Err <> 0) Then MsgBox "Command not available."
On Error GoTo 0
' Update the form.
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.Caption = Nz(Me![ItemText], "")
FillOptions

' Exit the application.
Case conCmdExitApplication
CloseCurrentDatabase

' Run a macro.
Case conCmdRunMacro
DoCmd.RunMacro rs![Argument]

' Run code.
Case conCmdRunCode
Application.Run rs![Argument]

' Open a Data Access Page
Case conCmdOpenPage
DoCmd.OpenDataAccessPage rs![Argument]

' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."

End Select

' Close the recordset and the database.
rs.Close

HandleButtonClick_Exit:
On Error Resume Next
Set rs = Nothing
Set con = Nothing
Exit Function

HandleButtonClick_Err:
' If the action was cancelled by the user for
' some reason, don't display an error message.
' Instead, resume on the next line.
If (Err = conErrDoCmdCancelled) Then
Resume Next
Else
MsgBox "There was an error executing the command.", vbCritical
Resume HandleButtonClick_Exit
End If

End Function
 
Comment out the line that says....

On Error GoTo HandleButtonClick_Err

Try it again and see where the debugger takes you to.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
I now receive this error msg after commenting On Error GoTo HandleButtonClick_Err

No debug button just an OK button. Looks like we are getting somewhere =)

The expression On Click you entered as the event property setting produced the following error.
Could not lock table 'Contacts'; currently in use by user 'Jeff Hargrove' on machine 'JHARGROVE'

* The expression may not result in the name of a macro, the name a user-defined function, or [Event Procedure].

* There may have been an error evaluating the function, event, or macro.
 
I went to TOOLS > OPTIONS > ADVANCED TAB

under the default record locking options

I tried selecting each option (No lock, All records, edited record) with Open databases using record-level locking checked and when running the database with users in it I still get the same error.

I've seen other forums with this same error msg and I havent seen a resolution for any of them. =\
 
Are you checking the properties of the actual forms to see if they are set to lock the table when it opens. This would be on the data tab of the form I believe.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
I don't think this error begins from the code of SwitchBoard. I had a Google search for the same. None of them has exact reply or reason to give.
It is something like stopping the second user from accessing to a already opened table (or Recordset).
To check this creat a new switchboard(don't use wizard) with placing some comand buttons to open the forms. Then try to use open the form.

Also try changing the RecordSet Type of the particular form.


Zameer Abdulla
Visit Me
 
So did you try creating your own switch board or menu form? Just create a form and put the buttons that do a simple DoCmd.OpenForm command.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top