tags:

views:

243

answers:

2

Here's the situation: I have a database application that the users run in Access 2003 runtime mode. I have a form that runs in Datasheet view. What I want to be able to do is allow the user to change the sort order while viewing this datasheet form. I have included the normal Access sort ascending/sort descending buttons on a custom toolbar. On my PC, with full version Access installed, these sorting buttons are enabled and I can sort.

Here's the problem: My users who run without full version of Access installed can see the buttons, but they are greyed-out/disabled.

Does anyone know of a way to enable those buttons in the run-time version of Access 2003?

+2  A: 

Actually the buttons should work in a datasheet view. However in a continuous form in the runtime environment they will NOT be enabled and they will not work.

The simple solution here is add a couple of your own custom buttons to that meuu bar.

Have those buttons call VBA code that simply sets the sort to ascending, or decending.

So, for the a->z buttion, change the on-action to:

=MySortDown()

(Remember to add some new buttons here, don't use the built in one says they'll be disabled - you can use the custom menu editor to copy the graphic images form the original buttons however)

And for the sort descending button, you can use:

=MySortUp()

Then in a standard code module, place the above two functions that will be called and they can be written as follows.

  Public Function mySortDown()

     Dim f    As Form
     Dim c    As Control
     Set f = Screen.ActiveForm

     Set c = f.ActiveControl

     f.OrderBy = c.ControlSource
     f.OrderByOn = True

  End Function

  Public Function mySortUp()

     Dim f    As Form
     Dim c    As Control
     Set f = Screen.ActiveForm

     Set c = f.ActiveControl

     f.OrderBy = c.ControlSource & " DESC"
     f.OrderByOn = True

  End Function

Followup:

I don’t have a reference for what works. However, during testing you can create a shortcut that allows you to test/run your code as if it is in runtime mode.

Just use:

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
"c:\program files\RidesXP\RidesXP.mdb"  /runtime

The above is on one line in the shortcut (and a space between each line).

As for the datasheet sort buttons not working, no problem. I think it might depend on which buttons you lifted from the built-in ones. Regardless, my sample/example code should work for either case.

Albert D. Kallal
Well, the form is definitely in datasheet view and the buttons are definitely grayed out while in runtime. I'll try your code out on Monday to see if that fixes the problem. Either way, where do you get the information about what will/will not work in runtime? Personal experience or do you have some authoratative source you trust?
KevenDenen
Tony Toews
Comment on Albert's Follow-up:I know about the /runtime switch and use that to test on my local machine. This is the first time that I've seen a difference between what happens when using the /runtime switch with full version installed and running on a machine with runtime and no full version. Thanks for your answer either way.
KevenDenen
A: 

Shortcut Menu

I tend to create a Custom Shortcut Menu on the Shortcut Menus toolbar with the built in Sort and Filter by Selection menu items. Then just set the text box Shortcut Menu Bar property for all controls that need to be able to sort.

The down side to this is the user needs to know to right click but it is very easy to set up for multiple forms.

Mark3308