简体   繁体   English

Microsoft Access If语句查询

[英]Microsoft Access If statement Query

I'm trying to figure out why my below query is not working. 我试图弄清楚为什么我下面的查询不起作用。

I have created a calculated field and as part of an IIf() I am looking at doing a LEFT function. 我已经创建了一个计算字段,并且作为IIf()一部分,我正在考虑执行LEFT函数。

I am hoping to return the First char of the Display Value of a column rather than the Hidden Primary Key. 我希望返回列显示值的第一个字符,而不是隐藏的主键。

Just wondering if someone can point me in the right direction? 只想知道是否有人可以指出我正确的方向?

在此处输入图片说明

You can debug this yourself by doing a couple of things. 您可以通过做几件事自己调试一下。 You haven't really provided specific information to what the problem you're facing. 您尚未真正提供所面临问题的特定信息。

First I would rewrite the query as such to reduce the number of paranthesis and make the intention/logic much clearer, which will also make it easier to debug. 首先,我将这样重写查询,以减少异常状态的数量,并使意图/逻辑更加清晰,这也将使其更易于调试。

IIf([General Notes] In ("FFA", "Consignment", "CCO", "Hargreaves", "SCRAP"), [General Notes], Left([Supplier_ID],1))

Then start with the following step and identify which field is causing the problem by breaking the query into seperate fields 然后,从以下步骤开始,通过将查询分为多个单独的字段来确定哪个字段导致了问题

IIf([General Notes] In ("FFA", "Consignment", "CCO", "Hargreaves", "SCRAP"), [General Notes], "") 
Left([Supplier_ID],1)
etc

As for the display value of the column rather than the hidden primary key, [Supplier_ID] sounds awfully like a name that would be given to a key. 至于列的显示值,而不是隐藏的主键, [Supplier_ID]听起来很像要为键指定的名称。 Perhaps you mean to place something like [Supplier_Name] or [Supplier] etc. 也许您的意思是放置类似[Supplier_Name][Supplier]等的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM