Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

[模块/函数] Dlookup多条件调用 报错

Diamond  发表于:2017-03-10 09:58:31  
复制

建立了四个表,分别是,报价,报价明细,订单,订单明细和一个查询,报价扩展。希望,通过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

Dlookup多条点击下载此附件件.zip


81.16 KB, 下载次数: 0


多条件报错

 

Top
MDZZ 发表于:2017-03-10 10:20:53

先不提Forms!orders1要不要加 符号   光这个'" & Forms!orders1!ID "'" And "[customer] = '" & Forms!orders1!customer"'" 写法就错误 

【Access扫盲知识】声明模块变量的用法,变量符号用法,文本型变量.日期型变量,数字型变量,数值型变量的符号表示法[Access软件网]

http://www.accessoft.com/article-show.asp?id=8013


至少该这个把 '" & Forms!orders1!ID& "'" And "[customer] = '" & Forms!orders1!customer & " '



Diamond 发表于:2017-03-10 10:27:22
看到了,能不能帮我改一下呀,这个还没有解决我的问题



Diamond 发表于:2017-03-10 10:38:46




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



总记录:3篇  页次:1/1 9 1 :