回复 2楼 cwa9958
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error Resume Next
Select Case Button.Index
Case 1
RS.MoveFirst
Case 2
RS.MovePrevious
If RS.BOF Then
RS.MoveFirst
End If
Case 3
RS.MoveNext
If RS.EOF Then
RS.MoveLast
End If
Case 4
RS.MoveLast
Case 5
If now_find Then
Frame2.Visible = False
Frame3.Visible = True
Frame4.Visible = False
Frame5.Visible = False
Frame6.Visible = False
Frame7.Visible = False
Text3.Text = ""
Text5.Text = ""
opname.Value = False
opshao.Value = False
For i = 1 To 4
Toolbar1.Buttons(i).Enabled = False
Next
Toolbar1.Buttons(6).Enabled = False
Toolbar1.Buttons(7).Enabled = False
Toolbar1.Buttons(8).Enabled = False
Toolbar1.Buttons(5).Caption = "确定"
Else
If Text3.Locked = False Then
RS.Filter = "名称 LIKE ( '*" & Trim(Text3.Text) & "*')"
ElseIf Text5.Locked = False Then
RS.Filter = "型号 LIKE ( '*" & Trim(Text5.Text) & "*')"
Else
MsgBox ("请写入查询条件")
Exit Sub
End If
If RS.EOF Then
MsgBox ("无所需查找的资料")
Exit Sub
End If
Label7.Caption = RS.RecordCount
Frame2.Visible = True
Frame3.Visible = False
Frame4.Visible = True
Frame5.Visible = True
Frame6.Visible = True
Frame7.Visible = True
For i = 1 To 4
Toolbar1.Buttons(i).Enabled = True
Next
Toolbar1.Buttons(6).Enabled = True
Toolbar1.Buttons(7).Enabled = True
Toolbar1.Buttons(8).Enabled = True
Toolbar1.Buttons(5).Caption = "查询"
Do While lsRS.EOF = False
lsRS.Delete
lsRS.MoveNext
Loop
Do While RS.EOF = False
lsRS.AddNew
For i = 0 To 52
lsRS.Fields(i) = RS.Fields(i)
Next
lsRS.Update
RS.MoveNext
Loop
RS.MoveFirst
End If
now_find = Not now_find
Exit Sub
Case 6
If now_add Then
Command1.Visible = True
old = RS.Bookmark
RS.AddNew
Text1(0).SelStart = 1
Text1(0).SelLength = Len(Text1(0).Text)
Text1(0).Text = "10kV***箱变新建工程"
Text1(1).Text = "10kV变压器试验报告"
Text1(2).Text = "S11-M-315/10"
Text1(4).Text = "重庆ABB变压器有限公司"
Text1(10).Text = "2022年4月1日"
Text1(5).Text = "10kV"
Text1(6).Text = "0.4kV"
Text1(7).Text = "315kVA"
Text1(8).Text = "DYn11"
Text1(9).Text = "on"
Text1(45).Text = "2kV耐压60s无异常"
Text1(46).Text = "100GΩ"
Text1(47).Text = "100GΩ"
Text1(44).Text = "200GΩ"
Text1(43).Text = "200GΩ"
Text1(53).Text = "28kV耐压60s无异常"
Text1(39).Text = "RBYQ-变压器直流电阻测试仪"
Text1(37).Text = "KZTX-6/0.25交流耐压调压控制器及变压器"
Text1(42).Text = "DM50C电子式绝缘电阻表"
Text1(52).Text = "2022年4月26日"
Toolbar1.Buttons(6).Caption = "确定"
Toolbar1.Buttons(7).Caption = "取消"
For i = 1 To 5
Toolbar1.Buttons(i).Enabled = False
Next
Toolbar1.Buttons(8).Enabled = False
Toolbar1.Buttons(9).Enabled = False
For i = 0 To 136
Text1(i).Locked = False
Next
For i = 0 To 27
Label8(i).Visible = True
Next
Else
If Text1(0).Text = "" Or Text1(1).Text = "" Or Text1(2).Text = "" Or Text1(3).Text = "" Or Text1(4).Text = "" Or Text1(5).Text = "" Or Text1(6).Text = "" Or Text1(7).Text = "" Or Text1(8).Text = "" Or Text1(9).Text = "" Or Text1(10).Text = "" Or Text1(35).Text = "" Or Text1(11).Text = "" Or Text1(17).Text = "" Or Text1(18).Text = "" Or Text1(19).Text = "" Or Text1(20).Text = "" Or Text1(21).Text = "" Or Text1(22).Text = "" Or Text1(23).Text = "" Or Text1(24).Text = "" Or Text1(25).Text = "" Or Text1(26).Text = "" Or Text1(27).Text = "" Or Text1(28).Text = "" Or Text1(29).Text = "" Or Text1(30).Text = "" Or Text1(31).Text = "" Then
MsgBox ("请填写带*号项"), vbOKOnly, "警告"
Exit Sub
Else
With RS
.Fields("项目名称") = Text1(0)
.Fields("名称") = Text1(1)
.Fields("型号") = Text1(2)
.Fields("制造编号") = Text1(3)
.Fields("制造厂家") = Text1(4)
.Fields("额定电压G") = Text1(5)
.Fields("额定电压D") = Text1(6)
.Fields("容量") = Text1(7)
.Fields("结线组别") = Text1(8)
.Fields("冷却方式") = Text1(9)
.Fields("出厂日期") = Text1(10)
.Fields("zzg1AB") = Text1(11)
.Fields("zzg1AC") = Text1(12)
.Fields("zzg1BC") = Text1(13)
.Fields("1phl") = Text1(14)
.Fields("zzg2AB") = Text1(15)
.Fields("zzg2AC") = Text1(16)
.Fields("zzg2BC") = Text1(17)
.Fields("2phl") = Text1(18)
.Fields("zzg3AB") = Text1(19)
.Fields("zzg3AC") = Text1(20)
.Fields("zzg3BC") = Text1(21)
.Fields("3phl") = Text1(22)
.Fields("zzg4AB") = Text1(23)
.Fields("zzg4AC") = Text1(24)
.Fields("zzg4BC") = Text1(25)
.Fields("4phl") = Text1(26)
.Fields("zzg5AB") = Text1(27)
.Fields("zzg5AC") = Text1(28)
.Fields("zzg5BC") = Text1(29)
.Fields("5phl") = Text1(30)
.Fields("zzda0") = Text1(31)
.Fields("zzdb0") = Text1(32)
.Fields("gjl") = Text1(33)
.Fields("djl") = Text1(34)
.Fields("zzdc0") = Text1(35)
.Fields("6phl") = Text1(36)
.Fields("耐压设备") = Text1(37)
.Fields("万用表") = Text1(38)
.Fields("直流电阻仪") = Text1(39)
.Fields("其它2") = Text1(40)
.Fields("其它1") = Text1(41)
.Fields("摇表") = Text1(42)
.Fields("耐压前绝缘G") = Text1(43)
.Fields("耐压后绝缘G") = Text1(44)
.Fields("低压侧交流耐压") = Text1(45)
.Fields("耐压前绝缘D") = Text1(46)
.Fields("耐压后绝缘D") = Text1(47)
.Fields("结论") = Text1(48)
.Fields("温度") = Text1(49)
.Fields("湿度") = Text1(50)
.Fields("试验人员") = Text1(51)
.Fields("试验日期") = Text1(52)
.Fields("高压侧交流耐压") = Text1(53)
.Fields("K设备名称") = Text1(54)
.Fields("K型号") = Text1(55)
.Fields("K出厂编号") = Text1(56)
.Fields("K额定电压") = Text1(57)
.Fields("K制造厂家") = Text1(58)
.Fields("K出厂日期") = Text1(59)
.Fields("K温度") = Text1(60)
.Fields("K湿度") = Text1(61)
.Fields("K试验人员") = Text1(62)
.Fields("K试验日期") = Text1(63)
.Fields("KSQD绝缘电阻A相") = Text1(64)
.Fields("KSQD绝缘电阻B相") = Text1(65)
.Fields("KSQD绝缘电阻C相") = Text1(66)
.Fields("KSHD绝缘电阻A相") = Text1(67)
.Fields("KSHD绝缘电阻B相") = Text1(68)
.Fields("KSHD绝缘电阻C相") = Text1(69)
.Fields("KSQX绝缘电阻A相") = Text1(70)
.Fields("KSQX绝缘电阻B相") = Text1(71)
.Fields("KSQX绝缘电阻C相") = Text1(72)
.Fields("KSHX绝缘电阻A相") = Text1(73)
.Fields("KSHX绝缘电阻B相") = Text1(74)
.Fields("KSHX绝缘电阻C相") = Text1(75)
.Fields("K回路电阻A相") = Text1(76)
.Fields("K回路电阻B相") = Text1(77)
.Fields("K回路电阻C相") = Text1(78)
.Fields("KD交流耐压A相") = Text1(79)
.Fields("KD交流耐压B相") = Text1(80)
.Fields("KD交流耐压C相") = Text1(81)
.Fields("KS交流耐压A相") = Text1(82)
.Fields("KS交流耐压B相") = Text1(83)
.Fields("KS交流耐压C相") = Text1(84)
.Fields("KJL交流耐压A相") = Text1(85)
.Fields("KJL交流耐压B相") = Text1(86)
.Fields("KJL交流耐压C相") = Text1(87)
.Fields("K仪器仪表1") = Text1(88)
.Fields("K仪器仪表2") = Text1(89)
.Fields("K仪器仪表3") = Text1(90)
.Fields("K结论") = Text1(91)
.Fields("B设备名称") = Text1(92)
.Fields("BA型号") = Text1(93)
.Fields("BA出厂编号") = Text1(94)
.Fields("BA生产厂家") = Text1(95)
.Fields("BA出厂日期") = Text1(96)
.Fields("BB型号") = Text1(97)
.Fields("BB出厂编号") = Text1(98)
.Fields("BB生产厂家") = Text1(99)
.Fields("BB出厂日期") = Text1(100)
.Fields("BC型号") = Text1(101)
.Fields("BC出厂编号") = Text1(102)
.Fields("BC生产厂家") = Text1(103)
.Fields("BC出厂日期") = Text1(104)
.Fields("BAU1mA") = Text1(105)
.Fields("BBU1mA") = Text1(106)
.Fields("BCU1mA") = Text1(107)
.Fields("BA泄漏") = Text1(108)
.Fields("BB泄漏") = Text1(109)
.Fields("BC泄漏") = Text1(110)
.Fields("BA试前绝缘") = Text1(111)
.Fields("BB试前绝缘") = Text1(112)
.Fields("BC试前绝缘") = Text1(113)
.Fields("BA试后绝缘") = Text1(114)
.Fields("BB试后绝缘") = Text1(115)
.Fields("BC试后绝缘") = Text1(116)
.Fields("B绝缘电阻仪型号") = Text1(117)
.Fields("B耐压设备型号") = Text1(118)
.Fields("B温度") = Text1(119)
.Fields("B湿度") = Text1(120)
.Fields("B试验人员") = Text1(121)
.Fields("B试验日期") = Text1(122)
.Fields("B结论") = Text1(123)
.Fields("J接地网名称") = Text1(124)
.Fields("J环境") = Text1(125)
.Fields("J接地极") = Text1(126)
.Fields("J接地带") = Text1(127)
.Fields("J制作方式") = Text1(128)
.Fields("J测试方法") = Text1(129)
.Fields("J测试结果") = Text1(130)
.Fields("J地阻表型号") = Text1(131)
.Fields("J温度") = Text1(132)
.Fields("J湿度") = Text1(133)
.Fields("J试验人员") = Text1(134)
.Fields("J试验日期") = Text1(135)
.Fields("J结论") = Text1(136)
.Update
总数.Caption = .RecordCount
End With
End If
Toolbar1.Buttons(6).Caption = "添加"
Toolbar1.Buttons(7).Caption = "更新"
Command1.Visible = False
For i = 1 To 5
Toolbar1.Buttons(i).Enabled = True
Next
Toolbar1.Buttons(8).Enabled = True
Toolbar1.Buttons(9).Enabled = True
For i = 0 To 136
Text1(i).Locked = True
Next
For i = 0 To 27
Label8(i).Visible = False
Next
End If
now_add = Not now_add
Exit Sub
Case 7
If now_add Then
old = RS.Bookmark
For i = 0 To 136
Text1(i).Locked = False
Next
Toolbar1.Buttons(6).Caption = "确定"
Toolbar1.Buttons(7).Caption = "取消"
For i = 1 To 5
Toolbar1.Buttons(i).Enabled = False
Next
Command1.Visible = True
For i = 0 To 27
Label8(i).Visible = True
Next
Toolbar1.Buttons(8).Enabled = False
Toolbar1.Buttons(9).Enabled = False
Else
RS.CancelUpdate
RS.Bookmark = old
Toolbar1.Buttons(6).Caption = "添加"
Toolbar1.Buttons(7).Caption = "更新"
Command1.Visible = False
For i = 1 To 5
Toolbar1.Buttons(i).Enabled = True
Next
Toolbar1.Buttons(8).Enabled = True
Toolbar1.Buttons(9).Enabled = True
For i = 0 To 136
Text1(i).Locked = True
Next
For i = 0 To 27
Label8(i).Visible = False
Next
End If
now_add = Not now_add
Exit Sub
Case 8
If RS.BOF = False Then
If MsgBox("确定要删除这条数据记录吗?", 36, "注意!") = 6 Then
RS.Delete
RS.MoveNext
If RS.EOF Then
RS.MoveLast
End If
End If
End If
总数.Caption = RS.RecordCount
Exit Sub
Case 9
If Not now_find Then
Frame2.Visible = True
Frame3.Visible = False
Frame4.Visible = True
Frame5.Visible = True
Frame6.Visible = True
Frame7.Visible = True
For i = 1 To 4
Toolbar1.Buttons(i).Enabled = True
Next
Toolbar1.Buttons(6).Enabled = True
Toolbar1.Buttons(7).Enabled = True
Toolbar1.Buttons(8).Enabled = True
Toolbar1.Buttons(5).Caption = "查询"
Else
Unload Me
End If
now_find = True
Exit Sub
End Select
End Sub
能帮我看下添加没问题更新不行