我做了一个 图书馆管理系统 里面的查书名 作者的这个查询理论一样的 我把代码复制在下面: 3个按钮为单选按钮 Private Sub Command4_Click() On Error GoTo error:
If Text1.Text <> "" Then If Option1.Value Then searchSQL = "SELECT * FROM 借阅 WHERE 图书名称=" & "'" & Text1.Text & "'" If Option2.Value Then searchSQL = "SELECT * FROM 借阅 WHERE 读者姓名=" & "'" & Text1.Text & "'" If Option3.Value Then searchSQL = "SELECT * FROM 借阅 WHERE 读者身份证号码=" & "'" & Text1.Text & "'" Else MsgBox "条件不能为空" Text1.SetFocus
End If Adodc1.RecordSource = searchSQL Adodc1.Refresh If Option1.Value Then If Adodc1.Recordset.EOF Then MsgBox "没有这本书!" End If Exit Sub End If If Option2.Value Then If Adodc1.Recordset.EOF Then MsgBox "没有这位读者!" End If Exit Sub End If If Option3.Value Then If Adodc1.Recordset.EOF Then MsgBox "没有这个身份证号!" End If Exit Sub End If error: MsgBox Err.Description End Sub