| 网站首页 | 新闻 | 新书 | 专家 | 技巧 | 源码作品 | 工具/资源 | 商城 | 风采 | 留言 | 论坛 | 网址 | 承接 | 
您现在的位置: Access/Office中国 >> 技巧 >> Access >> 编程心得绝招 >> 实际编程 >> 文章正文 用户登录 新用户注册
[图文]实现查询功能(DAO)         ★★★
实现查询功能(DAO)
作者:佚名 文章来源:网络 点击数: 本日:{$DayHits} 更新时间:2006-11-22 22:20:55
On Error GoTo 100
If TextBox1.Text = "" Then
MsgBox "请输入姓名", 1 + 16, "系统提示"
TextBox1.SetFocus
Else
    Dim RS1 As Recordset
    Dim DB1 As Database
    Set DB1 = OpenDatabase(ThisWorkbook.Path & "\" & "学生档案.MDB")
    Set RS1 = DB1.OpenRecordset(Name:="档案", Type:=dbOpenDynaset)
         RS1.FindFirst "姓名='" & TextBox1.Value & "'"
         If RS1.NoMatch = True Then
         MsgBox "对不起,没有该记录"
         RS1.Close
         Exit Sub
         Else
             TextBox2.Value = RS1.Fields("年龄").Value
             TextBox4.Value = RS1.Fields("性别").Value
             TextBox5.Value = RS1.Fields("籍贯").Value
             TextBox6.Value = RS1.Fields("联系电话").Value
            
       End If
    RS1.Close
    Set RS1 = Nothing
    Set DB1 = Nothing
   
End If
    Exit Sub
100:
    MsgBox "找不到符合条件的记录", 1 + 16, "系统提示"





On Error GoTo 100
If TextBox1.Text = "" Then
MsgBox "请输入姓名", 1 + 16, "系统提示"
TextBox1.SetFocus
Else
    Dim RS1 As Recordset
    Dim DB1 As Database
    Set DB1 = OpenDatabase(ThisWorkbook.Path & "\" & "学生档案.MDB")
    Set RS1 = DB1.OpenRecordset(Name:="档案", Type:=dbOpenDynaset)
         RS1.FindFirst "姓名='" & TextBox1.Value & "'"
         If RS1.NoMatch = True Then
         MsgBox "对不起,没有该记录"
         RS1.Close
         Exit Sub
         Else
             TextBox2.Value = RS1.Fields("年龄").Value
             TextBox4.Value = RS1.Fields("性别").Value
             TextBox5.Value = RS1.Fields("籍贯").Value
             TextBox6.Value = RS1.Fields("联系电话").Value
            
       End If
    RS1.Close
    Set RS1 = Nothing
    Set DB1 = Nothing
   
End If
    Exit Sub
100:
    MsgBox "找不到符合条件的记录", 1 + 16, "系统提示"




别人笑我太疯癫,我
文章录入:tm    责任编辑:tm 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    专 题 栏 目
    最 新 热 门
    最 新 推 荐
    相 关 文 章
    用Between 和 iif 实现灵
    查询在不同Web服务器上的
    一个常用的组合多条件查
    如何在查询中使用 AND 操
    怎样使用一个查询获得数
    不显示操作查询的系统提
    Web 查询保持Excel工作表
    运行操作查询词句更好的
    SQL中语法错误(操作符丢
    MS Jet SQL for Access 
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)