Office中国论坛/Access中国论坛

标题: Dlookup多条件调用 报错 [打印本页]

作者: 1768061209    时间: 2017-3-9 23:44
标题: Dlookup多条件调用 报错
本帖最后由 1768061209 于 2017-3-9 23:46 编辑

建立了四个表,分别是,报价,报价明细,订单,订单明细和一个查询,报价扩展。希望,通过Dlookup两重条件(ID=报价明细上面的ID,customer=报价上面的customer)以实现快制作订单的目的。
可是 不能自动跳

代码如下


Private Sub ID_AfterUpdate()
    '每次产品更改的初始价格和折扣
    If Not IsNull(Me![ID]) Then
        Me![列出价格] = GetListPrice(Me![ID])
       Me![标准成本] = GetStandardCost(Me![ID])
   
        
        
    '空产品订单表示用户要删除项目
    Else
        eh.TryToRunCommand acCmdDeleteRecord
    End If
End Sub

Function GetStandardCost(lID As String) As Currency
    GetStandardCost = DLookup("[标准成本]", "报价扩展", "[ID] =  '" & Forms!orders1!ID "'" And "[customer] ='" & Forms!orders1!customer"'")
End Function


Function GetListPrice(lID As String) As Currency
    GetListPrice = DLookup("[列出价格]", "报价扩展", "ID= '" & Forms!orders1!ID "'" And "[customer] = '" & Forms!orders1!customer"'")
End Function

作者: Henry D. Sy    时间: 2017-3-10 13:44
try
  1. Function GetStandardCost(lID As String) As Currency
  2.     GetStandardCost = DLookup("[标准成本]", "报价扩展", "[ID] =  '" & Forms!orders1!ID & "' And [customer] ='" & Forms!orders1!customer & "'")
  3. End Function
复制代码

作者: Henry D. Sy    时间: 2017-3-10 13:49
  1. Function GetListPrice(lID As String) As Currency
  2.     GetListPrice = DLookup("[列出价格]", "报价扩展", "ID= '" & Forms!orders1!ID & "' And [customer] = '" & Forms!orders1!customer & "'")
  3. End Function
复制代码

作者: 1768061209    时间: 2017-3-10 14:03
[attach]60923[/attach] 找不打ID额
作者: Henry D. Sy    时间: 2017-3-10 15:55
ID引用错误
作者: 1768061209    时间: 2017-3-10 16:53
怎么改呢?我看不出来哪里错了
作者: Henry D. Sy    时间: 2017-3-10 18:46
你好像是引用子窗体上的控件
作者: 1768061209    时间: 2017-3-10 19:00
是的。我试过单独引用子窗体的空间可以工作(ID)。加上customer,母窗体控件就不正常了。我想实现:建立了四个表,分别是,报价(主表),报价明细(从表),订单(主表),订单明细(从表)和一个查询,报价扩展。希望,通过Dlookup两重条件ID=报价明细(从表)上面的ID,customer=报价上面的customer(主表)以实现快速制作订单的目的。有没有什么办法?或者函数?




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3