复选框表单允许用户选择查询输出字段 [英] Checkbox form to allow user to select query output fields

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

问题描述

我是新手(2007年,在XP上运行),但到目前为止,我已经从我的项目中得到了一些很好的帮助。然而,我知道的越多,问题似乎就越复杂......


我在一张桌子上处理我的所有数据,现在,我有一个链接到查询的表单,允许用户通过各种控件输入他们想要的任何搜索条件。我还在表单上创建了一系列复选框,表示查询可能返回的每个可能字段(表中的列)。由于不是每个用户都需要或想要查看记录中包含的每个字段,我希望用户能够将查询返回的字段限制为他/她勾选的复选框。选择字段后,查询应照常运行,仅返回满足指定条件的记录,但仅显示框中勾选的字段。


我正在SQL View中构建查询,我认为这个问题的关键必须与SELECT相关。线。由于正常的固定场,查询具有要返回的字段

Hi, I''m new to access (2007, running on XP), but I''ve gotten some great help from this site on my project so far. However, the more I know, the more complex the problems seem to become....

I''m working with all of my data in a single table and, right now, I''ve got a form linked to a query that allows the user to input whatever search criteria they want through a variety of controls. I''ve also created a series of check boxes on the form representing every possible field (columns in the table) that the query could return. Since not every user needs or wants to see every field contained in the records, I would like the user to be able to limit the fields returned by the query to only the checkboxes he/she ticks. After the fields are selected, the query should run as usual, returning only the records that satisfy the specified criteria, but only displaying the fields ticked off in the boxes.

I''m building the query in SQL View, and I figure that the key to this must have something to do with the "SELECT" line. Since a normal "fixed-field" query has the fields to be return specified by

展开 | 选择 | Wrap | 行号

推荐答案

@dizzydangler


我希望每次我看到与一些非常先进的或与概念上的错误相关的东西时都有一英镑。这里的概念很好,但是你知道这是普通的,我不知道。听起来你不会有相关的经验知道。这当然不是问题。很奇怪,很多人都觉得他们可以判断他们什么时候才开始。
@dizzydangler


这会使它过于强烈。这种想法很有意义,但查询具有SQL定义的列(字段)。 Null值不会删除该字段。它只是为特定记录放入一个Null值。删除字段需要重新设计查询本身。这可以通过在SQL中动态添加字段来完成,但您仍需要QueryDef(保存的Access Query)对象进行更新。我不推荐这种方式,因为QueryDef每个字段的属性多于仅通过更改SQL创建的属性。


我要做的是创建一个模板QueryDef可能的字段完全按照您的要求设置。然后你(在运行时)做的是创建这个QueryDef的副本,然后更新该对象的SQL,从SELECT语句中删除必要的字段,或者使用VBA删除字段。


这些想法听起来如何?
@dizzydangler
I wish I had a pound for everytime I''ve seen that associated with something either extremely advanced or just plain wrong in concept. The concept here is fine, but where you get the idea this is ordinary from I have no idea. It doesn''t sound like you would have the relevant experience to know. This is not a problem of course. Just weird that so many people feel they are in a position to judge when they''re just starting out.
@dizzydangler
That would be putting it too strongly. The thinking makes sense, but queries have columns (Fields) as defined by the SQL. A Null value doesn''t remove the field. It simply puts a Null value in it for a particular record. Removing a field requires a redesign of the query itself. This can be done by adding the fields dynamically in SQL, but you would still need a QueryDef (saved Access Query) object to update. I wouldn''t recommend this way though, as a QueryDef has more attributes per field than are created simply by changing the SQL.

What I would do is create a template QueryDef with all possible fields set up perfectly as you would want them. What you then do (at run time) is create a copy of this QueryDef and then either update the SQL for that object, removing the fields necessary from the SELECT statement, or remove the fields using VBA.

How do these ideas sound to you?


另一个想法是像以前一样设计模板QueryDef,然后在VBA中创建SQL字符串,从这个QueryDef中选择而不是表。这样,无论如何,所有的字段大小和格式都会贯穿始终。遗憾的是,您仍然需要创建一个新的(可能只是临时的)QueryDef来显示值,因为如果没有SQL,则无法直接显示SQL。当然,如果您只希望将查询用作另一个对象(Report; Form; etc)的输入,那么这不再是真的。事实上,如果是这样的话,你首先不需要模板QueryDef。
Another thought would be to design the template QueryDef as before, but then create the SQL string in VBA selecting from this QueryDef instead of the table. That way all the field sizes and formats would carry through anyway. unfortunately you would still need to create a new (probably only temporary) QueryDef to display the values, as SQL cannot be displayed directly without one. Of course if you only want the query to be used as the input to another object (Report; Form; etc) then this is no longer true. In fact you wouldn''t really need the template QueryDef in the first place if that were the case.


我刚刚帮助了一个完全相同问题的人。我稍后会回来并使用示例代码解决方案发布我的方法。
I''ve just helped someone with the exact same problem. I''ll return later and Post my approach with the sample code solution.


这篇关于复选框表单允许用户选择查询输出字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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