根据从组合框中选择的表运行查询 [英] Run Query based off Table selected from Combo Box

查看:64
本文介绍了根据从组合框中选择的表运行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以这里是这样的情况:

我有一系列表,其中包含月度报告数据(每月1个表)。在这些表中是总视图列。我需要做的是计算2个不同月份中每个项目的总观看次数之间的差异(例如: [9月9日]![总观看次数] - [8月8日]![总观看次数] )。


我可以手动创建一个查询并将总视图字段设置为上述公式,并获得一个包含我想要的数据的表格。


这里'它变得棘手:我需要能够动态创建该查询(单击表单按钮),并根据具体内容将表格扩展到从表单上的组合框中选择。我将表单( frmDataPull )设置为向用户提供可供第1个月( cboMonth1 )和第2个月( cboMonth2 <)的表格列表/ b>)


在我的生活中我无法弄清楚如何设置查询以从cboMonth1选择/表中提取总视图数据并从cboMonth2选择中减去它/表。我需要输入字段和/或标准框才能使其生效?是否有任何编码需要在后台进行?


任何帮助将不胜感激;这个问题一直很令人烦恼......

解决方案

愿意提供帮助,但从提供的内容来看,这些都是非常具有推测性的。如果你能提供关于你的表格的详细信息,那将会有很大的帮助。


你在这里使用旧的工作簿>工作表的心态,这会给你带来很多问题!


我强烈建议您绝对停止正在做的事情并阅读以下内容:[*] (38.2 KB,332 views)


Ok, so here''s the situation:
I have a series of tables that have monthly reporting data in them (1 table for each month). In these tables is a ''Total Views'' column. What I need to do is calculate the difference between the Total Views of each item from 2 separate months (something like: [9-September]![Total Views]-[8-August]![Total Views]).

I can manually create a query and set the Total Views Field to the aforementioned formula and get a table with the data I want on it.

Here''s where it gets tricky: I need to be able to create that query ''on the fly'' (form button click) and have the tables it''s reaching out to based on what was selected from a combo box on the form. I have the form (frmDataPull) all set up to give the user a list of tables to select from for month 1 (cboMonth1) and month 2 (cboMonth2)

I cannot for the life of me figure out how to setup a query to pull the Total Views data from the cboMonth1 selection/table and subtract it from the cboMonth2 selection/table. What do I need to type into the Field and/or Criteria boxes to get this to work? Is there any coding that needs to take place in the background?

Any help would be greatly appreciated; this issue has been quite vexing...

解决方案

Would love to help, but from what is provided it would be all very speculative. If you could provide particulars about your tables it would help a lot.


You are using the old workbook>Worksheet mindset here and that will cause you a lot of issues!

I highly recommend that you absolutely stop what you are doing and read the following:[*]> Database Normalization and Table Structures.

I also have to agree with jforbes, you''ve not provided enough information on the table structures and their relationships; however, I suspect, once you normalize your data the issues you are having will solve themselves. Along with the details of your table structure, the version of Access and your level of Access knowledge will be most helpful.


So here''s a bit more information on the tables:
They contain records of knowledgebase article views for each month and have a PK of ''Article Number'' that is shared/linked in each month (table). I attached a screenshot of the relationships. What needs to happen is a query needs to take the data from the ''Article Views'' column in 1 table and subtract those numbers from the ''Article Views'' data in a second table (both tables selected from a form) and report the difference.

I''m not having issues with the data itself, I just don''t know how to do what needs to be accomplished. I have a pretty good understanding of Access & Databases (it''s just been a while since I worked with them). Also, I am using Access 2013.


Attached Images
MaintDB-Relationships.jpg (38.2 KB, 332 views)


这篇关于根据从组合框中选择的表运行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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