实现查询功能(DAO)
时间:2006-11-22 22:20 来源:网络 作者:佚名 阅读:次
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, "系统提示" |
别人笑我太疯癫,我 |
(责任编辑:admin)
顶一下
(0)
0%
踩一下
(0)
0%
相关内容
最新内容
推荐内容