访问查找表
我需要在 Access 中创建一个查找表,其中所有缩写都与一个值相关,如果缩写(在主表中)为空,那么我想显示“未知”
我得到了工作值,但我可以似乎没有让空值出现。
我的查找表看起来像这样:
REQUEST REQUEST_TEXT
------------------------
A Approve
D Disapprove
NULL N/A
但是当我按请求进行计数时,它只显示 A 和 D 的值,尽管我知道其中也有一些空白。
我做错了什么?
i need to create a lookup table in Access, where all the abbreviations are related to a value, and if the abbreviation (in the main table) is null, then i want to show "Unknown"
i got the values working, but i can't seem to get the nulls to show up.
my lookup table looks like this:
REQUEST REQUEST_TEXT
------------------------
A Approve
D Disapprove
NULL N/A
but when i do a count by request, it only shows me values for A and D, all though i know there are some blanks in there as well.
what am i doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您更改 tblLookup,这应该会更容易。
然后,在 tblMain 中,将 REQUEST 字段更改为必需 = True 和默认值 =“U”。添加新记录时,除非用户将其更改为 A 或 D,否则它们将具有 U 表示 REQUEST。
然后,在 REQUEST 上连接 2 个表的查询应该会得到我认为您想要的结果。
您还应该在两个表之间创建关系,并选择强制引用完整性的选项,以防止用户为 REQUEST 添加虚假值,例如“X”。
编辑:
如果无法更改 tblMain 结构,并且您是在 Access 会话中执行此操作,则可以在 LEFT JOIN 上使用 Nz() 函数。
如果您从 Access 会话外部(例如从 ASP)执行此操作,则 Nz() 函数将不可用。因此,您可以用 IIf() 表达式替换 Nz()。
Edit2:您不能直接使用 Null 值进行 JOIN。但是,对于我建议 tblLookup 的“Unknown”行,您可以使用包含 Nz 的 JOIN 进行 tblMain.REQUEST
如果您想将 tblLookup REQUEST 保留为 Null for REQUEST_TEXT = Unknown,我想您可以在 JOIN 的两侧使用 Nz表达。然而,加入 Nulls 的整个想法让我感到畏缩。我会修理桌子。
This should be easier if you change tblLookup.
Then, in tblMain, change the REQUEST field to Required = True and Default Value = "U". When new records are added, they will have U for REQUEST unless the user changes it to A or D.
Then a query which JOINs the 2 tables on REQUEST should get you what I think you want.
You should also create a relationship between the 2 tables, and select the option to enforce referential integrity in order to prevent the users from adding a spurious value such as "X" for REQUEST.
Edit:
If changing tblMain structure is off the table, and if you're doing this from within an Access session, you can use the Nz() function on a LEFT JOIN.
If you're doing this from outside an Access session, like from ASP, the Nz() function will not be available. So you can substitute an IIf() expression for Nz().
Edit2: You can't directly JOIN with Null values. However with the "Unknown" row I suggested for tblLookup, you could use a JOIN which includes Nz for tblMain.REQUEST
If you want to leave tblLookup REQUEST as Null for REQUEST_TEXT = Unknown, I suppose you could use Nz on both sides of the JOIN expression. However, this whole idea of joining Nulls makes me cringe. I would fix the tables instead.