Office中国论坛/Access中国论坛

标题: 查找数据问题 [打印本页]

作者: stvent    时间: 2011-5-1 08:00
标题: 查找数据问题
我有一表命名为“合同副”,当中有字段,“合同ID”,有一窗体命名为"合同录入",窗体中有一txtbox控件,如何在其afterupdata事件中,判断,当我输入合同副中不存在的合同ID后,弹出对话框,"不存存该合同ID"我使用dlookup,表示无效null错误!

作者: stvent    时间: 2011-5-1 08:03
本帖最后由 stvent 于 2011-5-1 14:33 编辑

以下是代码及出错信息
Dim htid As String
    htid = DLookup("合同ID", "合同副", "合同ID='" & Me.Parent!合同ID & "'")
    MsgBox htid



作者: stvent    时间: 2011-5-1 14:31

作者: 鱼儿游游    时间: 2011-5-2 01:55
本帖最后由 鱼儿游游 于 2011-5-2 01:56 编辑

Dim htid As String
    htid = Nz(DLookup("合同ID", "合同副", "合同ID='" & Me.Parent!合同ID & "'"),"")
    if  len(trim(htid)) >0 then
        MsgBox htid
   else
        Msgbox "无此合同"
   end if



作者: stvent    时间: 2011-5-2 11:04
鱼儿游游 发表于 2011-5-2 01:55
Dim htid As String
    htid = Nz(DLookup("合同ID", "合同副", "合同ID='" & Me.Parent!合同ID & "'")," ...

谢谢你!~




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