Link to home
Start Free TrialLog in
Avatar of Coghan
Coghan

asked on

Application.RunCommand acCmdSubformFormView Causes Runtime error 2501

I am developing a database for an overseas customer.  As there is a 5 hr time lag between us.. it is a bit hard for me to see what is going on exactly, but this is it in a nutshell.  On a main form, I have a subform SearchResults.  When the user selects a record in the subform and clicks a command button (cmdSwitch), the subform view toggles back and forth between datasheet and form view so that they can isolate some fields of interest.  

This works fine on my PC and laptops, and it works fine on my counterpart's laptop over there.  However, when the database was rolled out company wide over there, an error pops up (2501) whenever they hit the toggle button.  I have verified the obvious, like they are working with ACCESS 2000, etc.

Private Sub cmdSwitch_Click()
Me.SearchResults.Locked = False
If Me.SearchResults.Form.CurrentView = 1 Then
   Me.SearchResults.SetFocus
   Application.RunCommand acCmdSubformDatasheetView
Else
   Me.SearchResults.SetFocus
   Application.RunCommand acCmdSubformFormView
End If
Me.SearchResults.Locked = True
End Sub

In the debugger, the line Application.RunCommand gets highlighted.  I'm stumped.  If I could reproduce the error of course this would be easier, but I need to know what I can tell them to try without being able to put my hands on it.  Their developer at least is backing me up by showing that on his laptop, there are no errors.  First one to come up with the solution gets the points and an 'A'.  I'll try anything reasonable.

   
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

I believe that constant should be acCmdSubformDatasheet in Access 2000 ... then constant acCmdSubformDatasheetView was introduced after. If you have a machine with multiple versions (i.e. 2000, 2002, 2003 etc) then this would likely work. You should be able to use the acCmdSubFormDatasheet in both 2000 and later versions.

ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
are you running Access 2000 or Access 2003?

check if acCmdSubformDatasheetView is available in a2000  (cannot check no A2000)
sorry, Scott did not refresh
Avatar of Coghan
Coghan

ASKER

Thanks I will try taking 'View' off the end of the command.  It will be tomorrow before I can reply back and assign points, etc.  because of the time difference, but I'll be as prompt as possible.  Hopefully it is so simple.
No problem Rey ...
Avatar of Coghan

ASKER

Worked just fine.  Got confused on the toggle part for just a moment, the realized that it really meant just that.. one line toggles.. So anyway, they got back to me and it worked fine.  Thanks.