Dlookup有多个标准 [英] Dlookup with multiple criteria

查看:76
本文介绍了Dlookup有多个标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难让代码正确运行 - 想想我有一些引号不正确等等。对于正确的后续语法有任何帮助,我们将不胜感激:


DLookup(" [ [建筑规范]",tblConstructionCodes,[Walls] =''"& Forms![frmQuotation]![frmSituations]![Walls]&" and [Roof] = &&&&&&& ![frmQuotation]![frmSituations]![Roof]&"和[Floor] ="& Forms![frmQuotation]![frmSituations]![Floor]&" and [Frame] ="& ;表格![frmQuotation]![frmSituations]![Frame]&"''")

解决方案


我很难让代码正确运行 - 想想我有一些不正确的引号等任何关于正确语法的帮助将不胜感激:


DLookup(" [Construction] Code]"," tblConstructionCodes"," [Walls] =''"& Fo rms![frmQuotation]![frmSituations]![Walls]& 和[屋顶] =" &安培;表格![frmQuotation]![frmSituations]![屋顶]& "和[Floor] =" &安培;表格![frmQuotation]![frmSituations]![Floor]& "和[Frame] =" &安培;表格![frmQuotation]![frmSituations]![Frame]& "''")



我会通过使用变量来简化你的表达式,如下所示。变量应标识将控制表达式格式的数据类型。我假设您的构造代码的所有组件都是文本数据类型。如果不是这种情况,则需要相应地更改变量的数据类型。另外,基于表达式中使用的引用,我推断出被引用的控件在子表单上,并且已经更改了引用语法。希望这对你有用。让我知道。


Dim strWalls As String

Dim strRoof As String

Dim strFloor As String

Dim strFrame As String


strWalls =" Forms![frmQuotation]![frmSituations] .Form![Walls]"

strRoof =" ;表格![frmQuotation]![frmSituations] .Form![Roof]"

strFloor =" Forms![frmQuotation]![frmSituations] .Form![Floor]"

strFrame =" Forms![frmQuotation]![frmSituations] .Form![Frame]"


DLookup(" [Construction Code]"," ; tblConstructionCodes"," [Walls] =''"& strWalls&"''&" AND [Roof] =''"& strRoof&"''&" AND [Floor] =''"& strFloor&"''&" AND [Frame] =''"& strFrame&"''")


感谢您的回复。


好​​的 - 我已经给了一个去,但似乎没有o喜欢Dlookup中的单引号,从以下开始:


''" &安培; strRoof


还有其他建议吗?




I将使用如下所示的变量简化您的表达式。变量应标识将控制表达式格式的数据类型。我假设您的构造代码的所有组件都是文本数据类型。如果不是这种情况,则需要相应地更改变量的数据类型。另外,基于表达式中使用的引用,我推断出被引用的控件在子表单上,并且已经更改了引用语法。希望这对你有用。让我知道。


Dim strWalls As String

Dim strRoof As String

Dim strFloor As String

Dim strFrame As String


strWalls =" Forms![frmQuotation]![frmSituations] .Form![Walls]"

strRoof =" ;表格![frmQuotation]![frmSituations] .Form![Roof]"

strFloor =" Forms![frmQuotation]![frmSituations] .Form![Floor]"

strFrame =" Forms![frmQuotation]![frmSituations] .Form![Frame]"


DLookup(" [Construction Code]"," ; tblConstructionCodes"," [Walls] =''"& strWalls&"''&" AND [Roof] =''"& strRoof&"''&" AND [Floor] =''"& strFloor&"''&" AND [Frame] =''"& strFrame&"''")



感谢您的回复。


好​​的 - 我已经给了一个去,但它似乎不喜欢Dlookup中的单引号,从以下开始:


''" &安培; strRoof


还有其他建议吗?



如上所述,我假设所有变量都是文本字符串,语法反映了这一点。我将屋顶变量的变量数据类型更改为数字整数字符串和语法的变量数据类型,如下面修订的DLookup所示。您需要修改主字符串中任何其他数字子字符串的语法:

Dim strWalls As String

Dim intRoof As Integer

Dim strFloor As String

Dim strFrame As String


strWalls =" Forms![frmQuotation]![frmSituations] .Form![Walls]

intRoof = Forms![frmQuotation]![frmSituations] .Form![Roof]

strFloor =" Forms![frmQuotation]![frmSituations] .Form ![楼层]"

strFrame ="表格![frmQuotation]![frmSituations] .Form![Frame]"


DLookup(" ; [构造代码],tblConstructionCodes,[Walls] =''"& strWalls&"''&" AND [Roof] ="& intRoof&" AND [Floor] =''"& strFloor&"''&" AND [Frame] =''"& strFrame&"''")

>
--------------------------------------------- ---------------- -------------------


Am having difficulty getting code to run correctly - think I have a few quotation marks incorrect etc. Any help on correct syntax for following would be appreciated:

DLookup("[Construction Code]", "tblConstructionCodes", "[Walls]=''" & Forms![frmQuotation]![frmSituations]![Walls] & "and [Roof]=" & Forms![frmQuotation]![frmSituations]![Roof] & "and [Floor]=" & Forms![frmQuotation]![frmSituations]![Floor] & "and [Frame]=" & Forms![frmQuotation]![frmSituations]![Frame] & "''")

解决方案

Am having difficulty getting code to run correctly - think I have a few quotation marks incorrect etc. Any help on correct syntax for following would be appreciated:

DLookup("[Construction Code]", "tblConstructionCodes", "[Walls]=''" & Forms![frmQuotation]![frmSituations]![Walls] & "and [Roof]=" & Forms![frmQuotation]![frmSituations]![Roof] & "and [Floor]=" & Forms![frmQuotation]![frmSituations]![Floor] & "and [Frame]=" & Forms![frmQuotation]![frmSituations]![Frame] & "''")

I would simplify your expression by using variables as shown below. The variables should identify the datatype that will govern format of the expression. I have assumed that all of the components of your construction codes are text data types. If that isn''t the case, then the data type of the variable needs to be changed accordingly. In addition, based on the references used in the expression, I have deduced that the controls being referenced are on a subform, and have changed the reference syntax. Hope this works for you. Let me know.

Dim strWalls As String
Dim strRoof As String
Dim strFloor As String
Dim strFrame As String

strWalls = "Forms![frmQuotation]![frmSituations].Form![Walls]"
strRoof = "Forms![frmQuotation]![frmSituations].Form![Roof]"
strFloor = "Forms![frmQuotation]![frmSituations].Form![Floor]"
strFrame = "Forms![frmQuotation]![frmSituations].Form![Frame]"

DLookup("[Construction Code]", "tblConstructionCodes", "[Walls]=''" & strWalls & "'' & " AND [Roof] = ''" & strRoof & "'' & " AND [Floor] = ''" & strFloor & "'' & " AND [Frame] = ''" & strFrame & "''")


Thanks for your reply.

OK -I have given that a go but it doesn''t seem to like the single quotation marks in the Dlookup, starting with:

''" & strRoof

Any other suggestions?




I would simplify your expression by using variables as shown below. The variables should identify the datatype that will govern format of the expression. I have assumed that all of the components of your construction codes are text data types. If that isn''t the case, then the data type of the variable needs to be changed accordingly. In addition, based on the references used in the expression, I have deduced that the controls being referenced are on a subform, and have changed the reference syntax. Hope this works for you. Let me know.

Dim strWalls As String
Dim strRoof As String
Dim strFloor As String
Dim strFrame As String

strWalls = "Forms![frmQuotation]![frmSituations].Form![Walls]"
strRoof = "Forms![frmQuotation]![frmSituations].Form![Roof]"
strFloor = "Forms![frmQuotation]![frmSituations].Form![Floor]"
strFrame = "Forms![frmQuotation]![frmSituations].Form![Frame]"

DLookup("[Construction Code]", "tblConstructionCodes", "[Walls]=''" & strWalls & "'' & " AND [Roof] = ''" & strRoof & "'' & " AND [Floor] = ''" & strFloor & "'' & " AND [Frame] = ''" & strFrame & "''")


Thanks for your reply.

OK -I have given that a go but it doesn''t seem to like the single quotation marks in the Dlookup, starting with:

''" & strRoof

Any other suggestions?

As I discussed above, I assumed that all of the variables were text strings, and the syntax reflects that. I changed variable data type for the roof variable to that of a numeric integer string and syntax as shown in the revised DLookup below. You will need to modify the syntax for any other numeric substring within the main string:

Dim strWalls As String
Dim intRoof As Integer
Dim strFloor As String
Dim strFrame As String

strWalls = "Forms![frmQuotation]![frmSituations].Form![Walls]"
intRoof = Forms![frmQuotation]![frmSituations].Form![Roof]
strFloor = "Forms![frmQuotation]![frmSituations].Form![Floor]"
strFrame = "Forms![frmQuotation]![frmSituations].Form![Frame]"

DLookup("[Construction Code]", "tblConstructionCodes", "[Walls]=''" & strWalls & "'' & " AND [Roof] = " & intRoof & " AND [Floor] = ''" & strFloor & "'' & " AND [Frame] = ''" & strFrame & "''")

--------------------------------------------------------------------------------


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

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