| 实现查询功能(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 |
|
上一篇文章: 如何使 Microsoft Excel“总在前面”
下一篇文章: 用WINRAR作ACCESS备份 |
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |