设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1398|回复: 5
打印 上一主题 下一主题

[帮助] 求助各位高手帮忙完善代码,拜谢!

[复制链接]
跳转到指定楼层
1#
发表于 2011-11-7 22:02:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求助各位高手帮忙完善附件中的代码,达到我想要的功能,拜谢!{:soso_e183:}

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2011-11-8 10:25:45 | 只看该作者
Private Sub CmdCourseMngQuery_Click()
    Dim sLookFor As String
    Dim rs As Recordset

    sLookFor = ""
    If Text6 <> "" Then
        sLookFor = sLookFor & "模具编号='" & Text6 & "' and "
    End If
    If Text8 <> "" Then
        sLookFor = sLookFor & "零件名称='" & Text8 & "' and "
    End If
    If Text10 <> "" Then
        sLookFor = sLookFor & "编程员='" & Text10 & "' and "
    End If
    If Text12 <> "" Then
        sLookFor = sLookFor & "编程完成日期=#" & Text12 & "# and "
    End If

    If sLookFor <> "" Then
        sLookFor = Mid(sLookFor, 1, Len(sLookFor) - 5)
        Set rs = Me.加工信息.Form.Recordset
        rs.FindFirst sLookFor
        If rs.NoMatch Then
            MsgBox "没有找到"
        End If
        Me.加工信息.SetFocus
        Me.加工信息.Form.工序ID.SetFocus

        Me.加工信息.Form.Recordset.Bookmark = rs.Bookmark
        Set rs = Nothing
    Else
        MsgBox "请输入条件"
    End If

End Sub

Private Sub Command36_Click()
Text6 = ""
Text8 = ""
Text10 = ""
Text12 = ""
End Sub

写了一个查找和清空的代码,其它你再完善吧(因为其它的我没有看懂)
3#
 楼主| 发表于 2011-11-8 20:58:39 | 只看该作者
kangking 发表于 2011-11-8 10:25
Private Sub CmdCourseMngQuery_Click()
    Dim sLookFor As String
    Dim rs As Recordset

首先谢谢KANKING,老大的解答!基本达到我的第一个要求,但查询还不够准确,比如查找一个零件名称只能查到第一项记录,下面的记录就看不到,我要求查找到对象后,显示对象,其它无关的就隐藏起来。还望老大继续帮忙完善一下!第二项要求还望后面高手出招,谢谢!
4#
发表于 2011-11-9 11:35:22 | 只看该作者
ysh5858 发表于 2011-11-8 20:58
首先谢谢KANKING,老大的解答!基本达到我的第一个要求,但查询还不够准确,比如查找一个零件名称只能查到 ...

只怪我先前理解有误。
修改如下:
Private Sub CmdCourseMngQuery_Click()
    Dim sLookFor As String
   
    sLookFor = ""
    If Text6 <> "" Then
        sLookFor = sLookFor & "模具编号='" & Text6 & "' and "
    End If
    If Text8 <> "" Then
        sLookFor = sLookFor & "零件名称='" & Text8 & "' and "
    End If
    If Text10 <> "" Then
        sLookFor = sLookFor & "编程员='" & Text10 & "' and "
    End If
    If Text12 <> "" Then
        sLookFor = sLookFor & "编程完成日期=#" & Text12 & "# and "
    End If

    If sLookFor <> "" Then
        sLookFor = Mid(sLookFor, 1, Len(sLookFor) - 5)

        Me.加工信息.Form.Filter=slookfor
        Me.加工信息.Form.Filteron=true
    Else
        MsgBox "请输入条件"
    End If

End Sub

5#
 楼主| 发表于 2011-11-9 21:06:45 | 只看该作者
谢谢!第一步已达成,还望第二步有人出招!
6#
发表于 2011-11-23 21:38:26 | 只看该作者
学习。。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-5 08:25 , Processed in 0.086077 second(s), 30 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表