是否可以根据条件隐藏查询中的字段? [英] Is it possible to hide fields in a query based on criteria?

查看:96
本文介绍了是否可以根据条件隐藏查询中的字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个月度销售查询,按产品汇总每月销售额(每个月都有自己的字段,从去年1月到当年12月)。将提示此表的用户选择开始日期和结束日期,并根据给定的日期计算每个月的销售额(例如,如果输入的日期是7/18/2006和7/18/2007,则2006年1月至6月的所有产品的总和将为0,2006年7月至2007年7月将具有一定的价值。是否可以隐藏总和为0的字段?因此,如果月份不在所选的日期范围内,则不会显示这些月份的字段。


我不知道如何准确描述我对VBA的了解。我一直在学习。我通过表单为查询编写代码,这样用户就可以选择条件和订单(4个级别),并且工作完美。我喜欢认为,如果我看到一个代码,我可以弄清楚每个元素在做什么,但我仍然是初学者。


任何帮助都将不胜感激。


提前致谢,


Raza

Hi,

I have a monthly sales query that sums monthly sales by product (each month has its own field from January last year until December of the current year). A user of this table will be prompted to select a beginning date and an ending date and the sales for each month are calculated based on the dates given (say if the dates inputted are 7/18/2006 and 7/18/2007, the field for January-June 2006 will sum to 0 for all products and July 2006-July 2007 will have some value). Is it possible to hide the fields that sum to 0? So if the months are not within the date range selected, the fields for those months would not be shown.

I don''t know how to describe my knowledge of VBA exactly. I have been learning on the go. I wrote code for a query by form so a user would be able to select criteria and an order (4 levels) and it works perfect. I like to think that if I see a code I can figure out what each element is doing, but I''m still a beginner.

Any help will be appreciated.

Thanks in advance,

Raza

推荐答案


您好,


我有一个月度销售查询,按产品汇总每月销售额(每个月都有自己的字段,从去年1月到当年12月)。将提示此表的用户选择开始日期和结束日期,并根据给定的日期计算每个月的销售额(例如,如果输入的日期是7/18/2006和7/18/2007,则2006年1月至6月的所有产品的总和将为0,2006年7月至2007年7月将具有一定的价值。是否可以隐藏总和为0的字段?因此,如果月份不在所选的日期范围内,则不会显示这些月份的字段。


我不知道如何准确描述我对VBA的了解。我一直在学习。我通过表单为查询编写代码,这样用户就可以选择条件和订单(4个级别),并且工作完美。我喜欢认为,如果我看到一个代码,我可以弄清楚每个元素在做什么,但我仍然是初学者。


任何帮助都将不胜感激。


在此先感谢,


Raza
Hi,

I have a monthly sales query that sums monthly sales by product (each month has its own field from January last year until December of the current year). A user of this table will be prompted to select a beginning date and an ending date and the sales for each month are calculated based on the dates given (say if the dates inputted are 7/18/2006 and 7/18/2007, the field for January-June 2006 will sum to 0 for all products and July 2006-July 2007 will have some value). Is it possible to hide the fields that sum to 0? So if the months are not within the date range selected, the fields for those months would not be shown.

I don''t know how to describe my knowledge of VBA exactly. I have been learning on the go. I wrote code for a query by form so a user would be able to select criteria and an order (4 levels) and it works perfect. I like to think that if I see a code I can figure out what each element is doing, but I''m still a beginner.

Any help will be appreciated.

Thanks in advance,

Raza



SQL真的不是我的区域,但是您可能必须动态创建QueryDef(查询)对象,并仅构建SQL语句以显示明确包含在Range中的那些月。这有点棘手。我建议耐心等待,看看更多合格的SQL专家是否有不同的,更实用的方法。

SQL is really not my area, but you would probably have to dynamically create a QueryDef (Query) Object, and built the SQL Statement only to show those Months that are explicitly included within the Range. This would be a little tricky. I suggest being patient and see if more qualidfied SQL Experts have a different, and more practical, approach.



SQL真的不是我的区域,但您可能必须动态创建QueryDef(查询)对象,并仅构建SQL语句以显示明确包含在Range中的那些月。这有点棘手。我建议耐心等待,看看更多有资格的SQL专家是否有不同的,更实用的方法。
SQL is really not my area, but you would probably have to dynamically create a QueryDef (Query) Object, and built the SQL Statement only to show those Months that are explicitly included within the Range. This would be a little tricky. I suggest being patient and see if more qualidfied SQL Experts have a different, and more practical, approach.



是的,我一直在研究SQL的东西,但到目前为止还没有成功。


如果有人可以帮助或发布任何想法,我将不胜感激。

Yeah, I have been toying around with the SQL stuff, but have not been successful so far.

If anyone can help or post any ideas, i will appreciate it.


抱歉,我真的需要帮助。今天我将继续解决这个问题,但是如果有人能够指出我正确的方向,那么它会给我很多帮助并节省很多时间。
Sorry for the bump, but I really need help with this. I''m going to continue to tackle this today, but it would help me a lot and save me a lot of time if someone can at least point me in the right direction.


这篇关于是否可以根据条件隐藏查询中的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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