关于使用Min Total [英] About using Min Total

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

问题描述

我在Windows 8上使用Access 2013

我需要一些建议,以便使用Min Totals或其他路线的结果采取最佳方法。


我有:


父表 - 类 - 主键,类名和类详细信息。

子表 - 会话 - 主键,父外键,日期和详细信息。

一个类可以有多个会话,所有会话都有不同的日期。


填写这些表的表单:

主表格=父表格

连续子表格=子表格


每个班级的会话最小日期=班级开始日期。


目前我使用


查询 - 外键分组(Class)然后Class date = Min session date

此日期附加到

表 - 类日期和ClassID(上述父表的外键)


然后我在整个日期使用此日期数据库有很多公式和列表框s。


我试图找到一种方法将类日期表与上面提到的父表合并,但现在看来,这将创建一个循环引用。


但是我还需要考虑一个父表不应该有关于子表中记录的信息,这意味着它应该消失。


哪个让我需要用会话日期的Min来替换课程日期的使用,这将是一个主要的事业,我想正确地做。


写这篇文章时,它我突然意识到我可以:


- 删除班级日期表

- 让查询找到最小日期

让控件查看此查询而不是表格。


这会是有缺陷的逻辑吗?我觉得几分钟之前看起来很复杂的东西突然变得非常简单了。


我希望我能够很好地解释这种情况以获得一些建议。

感谢您抽出宝贵时间阅读本文。

解决方案

我认为你说得对。


只保留一个返回每个类的最小日期的查询。像使用任何其他表一样使用该查询。


至于使用它来获取有关原始类的数据,将它连接回类表来获取数据没有任何问题。没有循环引用,因为查询中的每个表引用都可以保持独立。这允许您执行诸如将表连接到自身之类的操作,这通常在您需要创建排名查询时完成。


感谢您的响应。我正在努力从使用表格切换到使用查询现在我已经确认了。


我不是很了解你的最后一段。

将它加入课堂表?

我要查找排名查询。


再次感谢。


< blockquote>自从我解决这个问题以来已经有一段时间了。上面,我使用了术语循环参考。因为以前,我把它作为错误信息。我现在不记得错误的确切情况。我只知道我设置的方式,如上所述,是我如何克服错误。既然我正在再次研究这个问题,我现在还记得我遇到的另一个问题。


当我使用min查询代替正在使用的表时,在表单或查询中,它使表单或查询无法添加新记录。


我不知道我做错了什么或如何处理这种情况。此日期是我整个数据库的中心。


请帮助。


I am using Access 2013 on Windows 8

I need some advice as to the best approach to take with using the results from Min Totals or using another route.

I have:

Parent Table - Classes - Primary Key, class name and class details.
Child Table - Sessions - Primary Key, Parent Foreign key, date and details.
One Class can have several Sessions all with different dates.

The form that fills in these tables:
Main form = Parent table
Continuous sub form = Child Table

Min date of the sessions for each class = class start date.

Currently I use

Query - Group by Foreign Key (Class) then Class date = Min session date
This date is appended to
Table - Class Date and ClassID (foreign key of the above parent table)

Then I use this date throughout the database in numerous formulas and list boxes.

I was trying to find a way to merge the class date table with the parent table mentioned above but as it stands now, this would create a circular reference.

But I also need to consider that a parent table should not have information about records in a child table, which means it should just go away.

Which leaves me needing to replace the use of class date with the use of Min of session date which will be a MAJOR undertaking and I would like to do it correctly.

While writing this, it just occurred to me that I could just:

- remove the Class date table
- keep the Query finding the min date
Have controls look to this query rather than the table.

Would this be flawed logic? I feel like something that seemed so complicated just a few minutes ago suddenly became pretty simple.

I hope I explained the situation well enough to receive some advice.

Thanks for taking the time to read this.

解决方案

I think you have it just right.

Keep just a query that returns the min date per class. Use that query like you would any other table.

As far as using it to get data about the original class, there''s nothing wrong with joining it back to the class table to get that data. There is no circular reference because each table reference in a query can remain separate. This allows you to do things such as joining a table to itself, this is often done when you need to create a ranking query.


Thanks for the response. I am working on switching from using the table to using the query now that I have confirmation.

I don''t really understand your last paragraph though.
Joining it back to the class table?
I am off to look up ranking query.

Thanks again.


It has been a while since I have worked on resolving this issue. Above, I used the term "circular reference" because previously, I was getting this as an error message. I don''t remember now the exact circumstances surrounding the error. I only know that the way I set things up, as described above, was how I got around the error. Now that I am working on this issue again, I now remember the other issue that I had.

When I use the min query in place of the table that was being used, in a form or query, it makes the form or query unable to add new records.

I don''t know what I am doing wrong or how to handle this situation. This date is the center of my entire database.

Help Please.


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

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