rs!电话 = \无\rs!地址 = \无\rs.Update End If rs.Close
Set rs = Nothing conn.Close
MsgBox \记录添加成功!\Unload Me
书库管理.Show End Sub
'------------------------------------- '修改记录事件
Private Sub Command2_Click() '修改记录
If Val(Label4.Caption) = 0 Then MsgBox \没有选择要修改的记录!\Exit Sub End If
Dim FL As String
FL = App.Path & \家庭书架.mdb\Set conn = OpenDatabase(FL)
strSQL = \* From 图书登记表 Where ID=\& Val(Label4.Caption) & \Set rs = conn.OpenRecordset(strSQL) rs.Edit
rs!名称 = Text2(0).Text rs!书号 = Text2(1).Text rs!作者 = Text2(2).Text rs!出版社 = Text2(3).Text rs!出借状态 = Combo2.Text rs!备注 = Text2(7).Text
If Combo2.Text = \出借\出借记录 = 1 rs.Update rs.Close
Set rs = Nothing
strSQL = \出借记录 Where zhuID=\\
Set rs = conn.OpenRecordset(strSQL) If Combo2.Text = \出借\If Not rs.EOF Then rs.Edit
rs!名称 = Text2(0).Text rs!借书人 = Text2(4).Text rs!电话 = Text2(5).Text
rs!地址 = Text2(6).Text rs.Update Else
rs.AddNew
rs!zhuID = Val(Label4.Caption) rs!名称 = Text2(0).Text rs!借书人 = Text2(4).Text rs!电话 = Text2(5).Text rs!地址 = Text2(6).Text rs.Update End If Else
If Not rs.EOF Then rs.Edit
rs!名称 = Text2(0).Text rs!借书人 = \没有出借\rs!电话 = \无\rs!地址 = \无\rs.Update Else
rs.AddNew
rs!zhuID = Val(Label4.Caption) rs!名称 = Text2(0).Text rs!借书人 = \没有出借\rs!电话 = \无\rs!地址 = \无\rs.Update End If End If rs.Close
Set rs = Nothing conn.Close
MsgBox \记录修改成功!\Label4.Caption = \Unload Me
书库管理.Show End Sub
'------------------------------------- '添加记录连接
Private Sub Command3_Click() Frame1.Visible = True Frame2.Visible = False Frame3.Visible = False ZFC = \添加\
For i = 0 To 7
Text1(i).Text = \Next i
Combo1.Text = \
Command1.Visible = True
Label5.Caption = \现在正在添加图书资料\End Sub
'------------------------------------- '修改记录连接
Private Sub Command4_Click() Frame1.Visible = False Frame2.Visible = True Frame3.Visible = False ZFC = \修改\For i = 0 To 7
Text2(i).Text = \Next i
Combo2.Text = \Label4.Caption = \
Command2.Visible = True
Label5.Caption = \现在正在修改图书资料\End Sub
'------------------------------------- '删除记录连接
Private Sub Command5_Click() Frame1.Visible = False Frame2.Visible = False Frame3.Visible = True ZFC = \删除\For i = 0 To 7
Text3(i).Text = \Next i
Combo3.Text = \Label1.Caption = \
Command6.Visible = True
Label5.Caption = \现在正在删除图书资料\End Sub
'------------------------------------- '删除记录事件
Private Sub Command6_Click() '删除记录
Dim SS As Integer
SS = MsgBox(\确实要删除这个记录吗?\If SS = 1 Then
删除确认!\If Val(Label1.Caption) = 0 Then MsgBox \没有选择要修改的记录!\Exit Sub End If
Dim FL As String, XID As Long FL = App.Path & \家庭书架.mdb\Set conn = OpenDatabase(FL)
strSQL = \* From 图书登记表 Where ID=\& Val(Label1.Caption) & \Set rs = conn.OpenRecordset(strSQL) rs.Delete rs.Close
Set rs = Nothing
strSQL = \出借记录 Where zhuID=\\
Set rs = conn.OpenRecordset(strSQL) rs.Delete rs.Close
Set rs = Nothing conn.Close
MsgBox \记录删除成功!\Unload Me
书库管理.Show Else
MsgBox \取消了删除记录!\End If End Sub
'------------------------------------- '页面启动事件
Private Sub Form_Load() Dim strSQL As String Frame1.Visible = False Frame2.Visible = False Frame3.Visible = False
Label5.Caption = \现在正在浏览图书资料\MS1.BackColorBkg = &HFFE0E0 End Sub
'------------------------------------- '点击MSHFlexGrid控件中记录的事件 Private Sub MS1_Click()
Dim i As Integer, COLX As Integer COLX = MS1.Col ROSX = MS1.Row
If ZFC = \添加\For i = 0 To 7
Text1(i).Text = \Next i
Combo1.Text = \
ElseIf ZFC = \修改\
Text2(0).Text = MS1.TextMatrix(ROSX, 1) Text2(1).Text = MS1.TextMatrix(ROSX, 2) Text2(2).Text = MS1.TextMatrix(ROSX, 3) Text2(3).Text = MS1.TextMatrix(ROSX, 4) Combo2.Text = MS1.TextMatrix(ROSX, 5) Text2(4).Text = MS1.TextMatrix(ROSX, 6) Text2(5).Text = MS1.TextMatrix(ROSX, 7) Text2(6).Text = MS1.TextMatrix(ROSX, 8) Text2(7).Text = MS1.TextMatrix(ROSX, 9) Label4.Caption = MS1.TextMatrix(ROSX, 0) Label5.Caption = \已经选择记录准备修改\ElseIf ZFC = \删除\
Text3(0).Text = MS1.TextMatrix(ROSX, 1) Text3(1).Text = MS1.TextMatrix(ROSX, 2) Text3(2).Text = MS1.TextMatrix(ROSX, 3) Text3(3).Text = MS1.TextMatrix(ROSX, 4) Combo3.Text = MS1.TextMatrix(ROSX, 5) Text3(4).Text = MS1.TextMatrix(ROSX, 6) Text3(5).Text = MS1.TextMatrix(ROSX, 7) Text3(6).Text = MS1.TextMatrix(ROSX, 8) Text3(7).Text = MS1.TextMatrix(ROSX, 9) Label1.Caption = MS1.TextMatrix(ROSX, 0) Label5.Caption = \已经选择记录准备删除\ElseIf ZFC = \CL = MS1.Col
For i = 1 To MS1.Cols MS1.Col = i - 1
MS1.CellBackColor = vbWhite Next i
MS1.Col = CL End If
MS1.Col = C0LX
MS1.CellBackColor = &H119911 End Sub
'------------------------------------- '离开该行时将该行的颜色恢复为白色的事件 Private Sub MS1_LeaveCell() Dim i As Integer Dim CL As Integer
'离开该行时将该行的颜色恢复为白色
CL = MS1.Col
For i = 1 To MS1.Cols MS1.Col = i - 1
MS1.CellBackColor = vbWhite Next i
MS1.Col = CL End Sub
下面是出现运行的情况: