bsp;Else
sql = sql & "and 书名='" & Trim(Combo1.Text & "'") & "'"
End If
End If
If Check3.Value = vbcheckde Then
If Trim(sql) = "" Then
sql = "作者='" & Trim(Text2.Text & " ") & "'"
Else
sql = sql & "and 作者='" & Trim(Text2.Text & " ") & "'"
End If
End If
If Check4.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "出版社='" & Trim(Text3.Text & " ") & "'"
Else
sql = sql & "and 出版社='" & Trim(Text3.Text & " ") & "'"
End If
End If
If Check5.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "书籍编号='" & Trim(Text4.Text & " ") & "'"
Else
sql = sql & "and 书籍编号='" & Trim(Text4.Text & " ") & "'"
End If
End If
If Trim(sql) = " " Then
MsgBox "请选择查询方式!", vbOKOnly + vbExclamation
Exit Sub
End If
Adodc1.RecordSource = "select * from sjxx where " & sql
Adodc1.Refresh
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
If Trim(book_num) = "" Then
MsgBox "请选择要借阅的图书!", vbOKOnly + vbExclamation
Exit Sub
End If
If panduan = "是" Then
MsgBox "此书已被借出!", vbOKOnly + vbExclamation
Exit Sub
End If
Form9.Show
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If Not Adodc1.Recordset.EOF And Adodc1.Recordset.EOF Then
book_num = DataGrid1.Columns(0).CellValue(DataGrid1.Bookmark)
panduan = DataGrid1.Columns(7).CellValue(DataGrid1.Bookmark)
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim sql As String
Combo1.Clear
Adodc2.Recordset.MoveFirst
For i = 0 To Adodc2.Recordset.RecordCount - 1
Combo1.AddItem Adodc2.Recordset.Fields(0).Value
Adodc2.Recordset.MoveNext
Next
Combo1.ListIndex = 0
End Sub
窗体名:Form5
代码:
Private Sub Command1_Click()
On Error GoTo command1error
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = True
Command5.Enabled = True
DataGrid1.AllowAddNew = True
DataGrid1.AllowUpdate = True
Exit Sub
commanderror:
MsgBox Err.Description
End Sub
Private Sub Command2_Click()
On Error GoTo Command2
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = True
Command5.Enabled = True
DataGrid1.AllowUpdate = True
Command2:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Private Sub Command3_Click()
Dim answer As String
On Error GoTo command3error
answer = MsgBox("确定要删除吗?", vbYesNo, "")
If answer = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
If Adodc1.Rec