问题描述
我很难让代码正确运行 - 想想我有一些引号不正确等等。对于正确的后续语法有任何帮助,我们将不胜感激:
DLookup(" [ [建筑规范]",tblConstructionCodes,[Walls] =''"& Forms![frmQuotation]![frmSituations]![Walls]&" and [Roof] = &&&&&&& ![frmQuotation]![frmSituations]![Roof]&"和[Floor] ="& Forms![frmQuotation]![frmSituations]![Floor]&" and [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&"''")
如上所述,我假设所有变量都是文本字符串,语法反映了这一点。我将屋顶变量的变量数据类型更改为数字整数字符串和语法的变量数据类型,如下面修订的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] & "''")
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 & "''")
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有多个标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!