表使用相同名称时,请参阅查询中的字段 [英] Refer to field in query when tables use same name

查看:55
本文介绍了表使用相同名称时,请参阅查询中的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有where语句的OpenForm会引发错误,因为我试图打开的表单使用的查询有两个来自不同表的字段共享同一个名称。


让我解释一下这是如何相关的。我已经创建了一个项目经理计划。


我有一个Projects(TBProjects)表,其中包含ProjectID,ProjectName和StatusID(以及其他)字段。


另一个任务表(TBTasks)。 Tasks表包含TaskID,ProjectID,StartDate,EndDate和StatusID(以及其他)的字段。


然后另一个Status(TBStatus)表,其中'StatusID''表示1表示未启动,2表示正在进行,3表示已完成。


我想打开一个表单,只显示TBTasks中针对特定项目的记录(通过ProjectID),并且(A)未启动和(B)未启动和过期和(C)已启动但已结束由于。


为此,必须使用上面提到的TBTasks中的所有三个字段,StartDate,EndDate和Status。

因此我的OpenForm看起来相当复杂

I have an OpenForm with a where statement which throws up an error because the form i''m trying to open uses a query which has two fields from different tables sharing the same name.

Let me explain how this relates. I''ve create a Project Manager program.

I have a table for Projects (TBProjects) with fields ''ProjectID'', ''ProjectName'' and ''StatusID''(plus others).

Another table for the Tasks (TBTasks). The Tasks table has fields for ''TaskID'', ''ProjectID'', ''StartDate'', ''EndDate'' and ''StatusID''(plus others).

Then another table for Status (TBStatus) with the ''StatusID'' indicating 1 for Not Started, 2 for In Progress and 3 for Completed.

I want to open a form that shows only those records in TBTasks that are for a specific Project(via ProjectID) and are (A) Not Started AND (B) Not Started and Over Due AND (C) Started but Over Due.

To do this the all three fields in TBTasks mentioned above must be used, ''StartDate'', ''EndDate'' and ''Status''.
Therefore my OpenForm looks quite complex

展开 | 选择 | Wrap | 行号

推荐答案

您好

基于SQL是?FRMTasksByProjectOverDue的记录源?表单,然后我会建议在这个SQL中使用别名像这样

Hi

On the basis that the SQL is the Record Source for the ?FRMTasksByProjectOverDue? form, then I would suggest using aliases in this SQL like this

展开 | 选择 | Wrap | 行号


好思维迈克。不幸的是,我不相信Jet SQL会在WHERE子句中处理ALIAS。为了公平起见Reginald几乎在那里尝试[TBTasks.StatusID],因为它应该是[TBTasks]。[StatusID]。 TBTasks.StatusID也可以工作。方括号([])应仅包含元素项。不合格的参考。 [TBTasks]和[StatusID],但从不[TBTasks.StatusID]。
Good thinking Mike. Unfortunately I don''t believe Jet SQL handles ALIASes in the WHERE clause though. To be fair Reginald was almost there when he tried [TBTasks.StatusID], as it should be [TBTasks].[StatusID]. TBTasks.StatusID may also work. The square brackets ([]) should surround elemental items only. Not qualified references. [TBTasks] and [StatusID], but never [TBTasks.StatusID].


你好NeoPa


我只能说别名总是我曾经在那里工作过,包括''Where''条款开放形式!!


我可能没有尝试过吗?


MTB
Hi NeoPa

All I can say is that aliases have always worked for me where ever I have used then, including ''Where'' clause opening forms!!

May be I havn''t tried had enough?

MTB


这篇关于表使用相同名称时,请参阅查询中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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