在dbcombo、dblist、datacombo、datalist中用以下方式:
' 查询
Private Sub cmdserch_Click()
Dim x As String
'定义查找方式
DBList1.MatchEntry = dblBasicMatching
x = InputBox("请输入要查询的姓名", "查询", DBList1.Text)
If Trim(x) = vbNullString Then Exit Sub
DBList1.Text = x
If Not (DBList1.MatchedWithList) Then
MsgBox "数据库中没有姓名为“" & x & "”的记录", vbExclamation, "查找"
Else
Text1.Text = DBList1.BoundText
End If
End Sub
在 adodc中
' 查询
Private Sub cmdserch_Click()
Dim x As String
x = InputBox("请输入要查询的姓名", "查询")
If Trim(x) = vbNullString Then Exit Sub
adodc1.Recordset.Find "姓名" & "=" & "'" & x & "'"
If adodc1.Recordset.EOF Then
MsgBox "数据库中没有姓名为“" & x & "”记录", vbExclamation, "查找"
End If
End Sub
在 data中
' 查询
Private Sub cmdserch_Click()
Dim texfind As String
texfind = InputBox("请输入要查询的姓名", "查询")
If Trim(texfind) = vbNullString Then Exit Sub
' 进行根据选择条件查询
Data1.Recordset.FindFirst "姓名" & "=" & "'" & texfind & "'"
' 如果没有找到记录NoMatch的值为True,找到记录NoMatch的值为False
If Data1.Recordset.NoMatch = True Then
MsgBox "数据库中没有姓名为“" & texfind & "”的记录", vbExclamation, "查找"
End If
End Sub
' 查询
Private Sub cmdserch_Click()
Dim x As String
'定义查找方式
DBList1.MatchEntry = dblBasicMatching
x = InputBox("请输入要查询的姓名", "查询", DBList1.Text)
If Trim(x) = vbNullString Then Exit Sub
DBList1.Text = x
If Not (DBList1.MatchedWithList) Then
MsgBox "数据库中没有姓名为“" & x & "”的记录", vbExclamation, "查找"
Else
Text1.Text = DBList1.BoundText
End If
End Sub
在 adodc中
' 查询
Private Sub cmdserch_Click()
Dim x As String
x = InputBox("请输入要查询的姓名", "查询")
If Trim(x) = vbNullString Then Exit Sub
adodc1.Recordset.Find "姓名" & "=" & "'" & x & "'"
If adodc1.Recordset.EOF Then
MsgBox "数据库中没有姓名为“" & x & "”记录", vbExclamation, "查找"
End If
End Sub
在 data中
' 查询
Private Sub cmdserch_Click()
Dim texfind As String
texfind = InputBox("请输入要查询的姓名", "查询")
If Trim(texfind) = vbNullString Then Exit Sub
' 进行根据选择条件查询
Data1.Recordset.FindFirst "姓名" & "=" & "'" & texfind & "'"
' 如果没有找到记录NoMatch的值为True,找到记录NoMatch的值为False
If Data1.Recordset.NoMatch = True Then
MsgBox "数据库中没有姓名为“" & texfind & "”的记录", vbExclamation, "查找"
End If
End Sub