使用Access运行时排序 [英] Sorting while using Access runtime

查看:99
本文介绍了使用Access运行时排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况如下: 我有一个数据库应用程序,用户可以在Access 2003运行时模式下运行.我有一个在数据表视图中运行的表单.我想做的是允许用户在查看此数据表表单时更改排序顺序.我在自定义工具栏上包含了普通的Access升序/降序按钮.在安装了完整版Access的PC上,启用了这些排序按钮,我可以进行排序.

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.

这是问题所在: 没有安装完整版本的Access的用户可以看到这些按钮,但是它们显示为灰色/禁用.

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

有人知道在Access 2003的运行时版本中启用那些按钮的方法吗?

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

推荐答案

实际上,这些按钮应该在数据表视图中起作用.但是,在运行时环境中,它们将以连续的形式被启用,并且将无法正常工作.

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.

让这些按钮调用VBA代码,该代码仅将排序设置为升序或降序.

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

因此,对于a-> z按钮,将启用操作更改为:

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

= MySortDown()

=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()

=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

跟进:

对于有效的方法,我没有任何参考.但是,在测试过程中,您可以创建一个快捷方式,使您可以像在运行时模式下一样测试/运行代码.

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.

只需使用:

"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.

这篇关于使用Access运行时排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆