Ms-access 中的查询

发布于 2024-09-18 22:25:43 字数 2925 浏览 9 评论 0原文

此查询显示事件类型不等于“PNremoved FROM Wrapper”的零件编号。此查询显示正确的数据。部件号可能会从此跟踪号中删除,但可以使用另一个跟踪号进行输入。在这种情况下它不起作用。

我希望当我们输入与另一个跟踪号码相同的零件号时查询能够工作。

部件号不应与我们使用 eventtype=“pn 从包装中删除”的跟踪号一起显示。但它应该与具有相同部件号的另一个跟踪号一起显示。

SELECT
    tblRevRelLog_Detail.RevRelTrackingNumber,
    tblRevRelLog_Detail.PartNumber,
    tblRevRelLog_Detail.ChangeLevel,
    tblRevRelLog_Detail.Version,
    tblRevRelLog_Detail.JobPnType,
    tblRevRelLog_Detail.EdsName,
    tblRevRelLog_Detail.DetailerNamePerPartNumber,
    tblRevRelLog_Detail.DetailerCompanyPerPartNumber
FROM
    tblRevRelLog_Detail LEFT JOIN tblEventLog
    ON tblRevRelLog_Detail.PartNumber = tblEventLog.PartNumber
WHERE
    tblEventLog.PartNumber Not In (
        SELECT tblEventLog.PartNumber
        FROM tblEventLog
        WHERE tblEventLog.EventTypeSelected = 'pn REMOVED From Wrapper')
ORDER BY
    tblRevRelLog_Detail.PartNumber;

我用一个例子来展示这一点。

Reviewrelease_Form(主窗体)链接到 reviewreleasetable:

此表包含基本数据和包装编号

                wrapper number:  Testing

RevRel_Form(子窗体)链接到 tblRevRelLog_Detail

此窗体包含有关零件号的数据

part no   chnglvl  jobpntype engineername company version
8765        1         XXXX      XXXXX       XXXX    xxxx
9898        0         xxxx       xxxxx      xxxx     xxxx
7889        2          xxxx      xxxxx       xxxx    xxxx

eventhistory(子窗体)链接到 tblEventLog

此窗体包含与零件号发生的事件

eventdate   partnum    eventtype       errortype     errorsubtype  comment

xxxxx        8765       1-receive new   xxxx           xxxx        xxxxx
xxxx         9898       1-recieve new   xxxx           xxxx        xxxxx
xxxx         7889       1-receive new   xxxx           xxxx          xxxx
xxxx         8765       2-assign        xxxx            xxx          xxx
xxx          9898       3 errors        xxxx            xxxx         xxxx

如果我想要要从包装器中删除零件编号,我将删除并且事件历史记录表单如下所示

eventdate   partnum    eventtype       errortype     errorsubtype  comment

xxxxx        8765       1-receive new   xxxx           xxxx        xxxxx
xxxx         9898       1-recieve new   xxxx           xxxx        xxxxx
xxxx         7889       1-receive new   xxxx           xxxx          xxxx
xxxx         8765       2-assign        xxxx            xxx          xxx
xxx          9898       3 errors        xxxx            xxxx         xxxx
xxx          9898       'pn REMOVED....' xxx             xxx        xxxx

然后 RevRel_Form 不应显示此零件编号数据,如下所示:

part no   chnglvl  jobpntype engineername company version
8765        1         XXXX      XXXXX       XXXX    xxxx
7889        2          xxxx      xxxxx       xxxx    xxxx

这与我在 RevRel_form 的数据源中编写的查询配合良好(我上面写的查询)。

但问题是,被删除的零件编号将来会再次出现,并带有另一个新的包装编号。对于我现在使用的查询,它也不会显示带有新包装编号的零件编号数据。

因此,我希望查询能够使用新的包装编号在 RevRel_Form 中显示零件编号数据。但与我们删除该零件编号的包装编号不同。

如果您无法看到正确格式的记录,请在编辑视图中查看它们。

This query displays partnumbers which have eventtype is not equal to "PNremoved FROM Wrapper". This query is displaying the right data. Part number may be removed from this tracking number, but it can be entered using another tracking number. In that case it is not working.

I want the query that works when we enter the same part number with another tracking number.

Part number should not display with the tracking number with which we have used eventtype= "pn Removed from wrapper". But it should display with the another tracking number that has the same part number.

SELECT
    tblRevRelLog_Detail.RevRelTrackingNumber,
    tblRevRelLog_Detail.PartNumber,
    tblRevRelLog_Detail.ChangeLevel,
    tblRevRelLog_Detail.Version,
    tblRevRelLog_Detail.JobPnType,
    tblRevRelLog_Detail.EdsName,
    tblRevRelLog_Detail.DetailerNamePerPartNumber,
    tblRevRelLog_Detail.DetailerCompanyPerPartNumber
FROM
    tblRevRelLog_Detail LEFT JOIN tblEventLog
    ON tblRevRelLog_Detail.PartNumber = tblEventLog.PartNumber
WHERE
    tblEventLog.PartNumber Not In (
        SELECT tblEventLog.PartNumber
        FROM tblEventLog
        WHERE tblEventLog.EventTypeSelected = 'pn REMOVED From Wrapper')
ORDER BY
    tblRevRelLog_Detail.PartNumber;

I am showing this by using an example.

Reviewrelease_Form(main form) linked to reviewreleasetable:

this table contains basic data and wrapper number

                wrapper number:  Testing

RevRel_Form(subform) linked to tblRevRelLog_Detail

This form contains data about the part number

part no   chnglvl  jobpntype engineername company version
8765        1         XXXX      XXXXX       XXXX    xxxx
9898        0         xxxx       xxxxx      xxxx     xxxx
7889        2          xxxx      xxxxx       xxxx    xxxx

eventhistory(subform) linked to tblEventLog

This form contains events happended with part numbers

eventdate   partnum    eventtype       errortype     errorsubtype  comment

xxxxx        8765       1-receive new   xxxx           xxxx        xxxxx
xxxx         9898       1-recieve new   xxxx           xxxx        xxxxx
xxxx         7889       1-receive new   xxxx           xxxx          xxxx
xxxx         8765       2-assign        xxxx            xxx          xxx
xxx          9898       3 errors        xxxx            xxxx         xxxx

If i want to remove a part number from the wrapper, I will remove and the eventhistory form looks as shown below

eventdate   partnum    eventtype       errortype     errorsubtype  comment

xxxxx        8765       1-receive new   xxxx           xxxx        xxxxx
xxxx         9898       1-recieve new   xxxx           xxxx        xxxxx
xxxx         7889       1-receive new   xxxx           xxxx          xxxx
xxxx         8765       2-assign        xxxx            xxx          xxx
xxx          9898       3 errors        xxxx            xxxx         xxxx
xxx          9898       'pn REMOVED....' xxx             xxx        xxxx

Then the RevRel_Form should not display this partnumber data as follows:

part no   chnglvl  jobpntype engineername company version
8765        1         XXXX      XXXXX       XXXX    xxxx
7889        2          xxxx      xxxxx       xxxx    xxxx

This is working fine with the query that I have written in the Data source of the RevRel_form (The query that i have written above).

But the problem is, removed part number will come again with another new wrapper number in the future. with the query I am using right now, It would not display the partnumber data with the new wrapper number aswell.

So, I want the query that displays partnumber data in the RevRel_Form with new wrapper number. But not with the wrapper number in which we removed that part number.

If you cannot see records in the right format, check them out in the edit view.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

病女 2024-09-25 22:25:43

你需要添加对包装器的引用,例如:

WHERE
    tblEventLog.wrapper = 'wrapper id'
    AND tblEventLog.EventTypeSelected <> 'pn REMOVED From Wrapper'

如果事件日志不包含包装器id,我认为你有设计问题,因为这些事件显然适用于特定的包装器。

You need to add a reference to the wrapper, for example:

WHERE
    tblEventLog.wrapper = 'wrapper id'
    AND tblEventLog.EventTypeSelected <> 'pn REMOVED From Wrapper'

If the event log does not contain a wrapper id, I think you have a design problem, because these events clearly apply to a particular wrapper.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文