我的表单如何允许用户选择要排序的字段? [英] How can my form allow the user to select fields to sort on?

查看:62
本文介绍了我的表单如何允许用户选择要排序的字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由SQL程序员创建的数据库,除了程序员从未完成它之外,它一切都很棒,而且对我的用户社区来说它非常复杂,这意味着没有人可以完成或者维护它。


我正在重写它的功能(并完成它!),以便它只使用熟悉的Access实用程序。它不需要任何花哨的东西,所以虽然它需要我一点时间才能完成,但是用户可以更加简单地维护它们。


目前,有一个表单提供一个非绑定控件,用作特定字段的过滤器,以及三对控件,每对控件允许用户选择字段和排序顺序那个领域。 (我附上了表格的图片。)


基础代码只运行一个查询并显示数据表,但我希望以合理的方式呈现数据形成而不仅仅是在一个笨拙的领域向右边行进。这是代码,如何使代码使用我创建的表单而不仅仅是原始查询:

I have a database that was created by a SQL programmer, and it''s all wonderful, except that the programmer never completed it, and it''s pretty sophisticated for my user community, so that means no one can complete it or maintain it.

I''m re-writing its functionality (and completing it!) so that it just uses familiar Access utilities. It doesn''t need anything fancy, so although it''s taking me a little time to accomplish, it''s going to be simpler for the users to maintain, to the extent that they are able.

Currently, there is a form that presents one unbound control that functions as a filter for a specific field, and three pairs of controls, each pair of which allows the user to select a field and a sort order for that field. (I''ve attached a picture of the form.)

The underlying code simply runs a query and presents the data table, but I want to present the data in a sensibly-designed form instead of just in an unwieldly line of fields marching off to the right. Here''s the code, and how do I make the code use the form I''ve created instead of just the raw query:

展开 | 选择 | Wrap | 行号

推荐答案

这听起来很有趣苏。
This sounds like some fun Sue.
  1. 首先设计一个表格将根据您的需要显示数据。这将用于显示已经过滤并按三个字段排序的数据。
  2. 对于过滤,我建议您去在表单上过滤示例。它包含一个可以使用的示例数据库,其工作方式类似于过滤概念的教程。它涵盖了完成这项工作所需的大部分内容。
  3. 使用三对控件中指定的三个字段对数据进行排序相似但略有不同。您将使用这些控件中的数据形成 OrderBy 字符串,该字符串与基础查询的SQL的ORDER BY子句匹配。不幸的是,虽然过滤由 DoCmd.OpenForm()的参数支持,但排序却不是。这意味着您需要在表单打开后应用它。这可以通过将数据作为 OpenArgs 传递或在表单打开后在调用代码中显式设置属性来完成。如果您认为这条路线对您有吸引力,我们可以在以后详细说明。
  1. Start by designing a form that will show the data as you want it. This is what you will use to display the data that you have filtered and sorted by your three fields.
  2. For the filtering, I suggest you go and have a play in Example Filtering on a Form. It includes an example database you can play with, and works like a tutorial for the concept of filtering. It covers most of what you need to do this whole job.
  3. The sorting of the data using the three fields specified in your three pairs of controls is similar but slightly different. You will use the data in these controls to form an OrderBy string which matches the ORDER BY clause of the SQL of the underlying query. Unfortunately, whereas the filtering is supported by a parameter to DoCmd.OpenForm(), the sorting is not. This means you will need to apply this after the form has already been opened. This can be done by passing the data as OpenArgs or setting the properties explicitly in the calling code after the form''s been opened. We can cover details for this later should you decide this route appeals to you.



实际上,就是这样。这是一个很好的方法,使它看起来很专业。我喜欢它。


Actually, that will be it. It''s a good approach and makes it look professional. I like it.


谢谢你, NeoPa!我今晚下班后肯定会潜入这里,并会报告回来(当然,你知道我会,因为是进一步的问题!:D)
Thanks for this, NeoPa! I certainly will dive into this this evening after work, and will report back (of course, you know I will, since there will be further questions! :D)


我以为我现在只是查看那个帖子,即使我还没有开始,但链接或页面或某些东西必定是错误的,因为每次点击它都会出错。
I thought I''d just check out that thread now, even though I can''t start on it yet, but something must be wrong with the link or page or something cuz I get an error every time I click on it.


这篇关于我的表单如何允许用户选择要排序的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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