哪位大哥帮帮忙……
我在做一个数据库,数据库中有两个表,“all”与“single”,一个是放全部的数据,一个是临时数据,存放查询时的数据和当前表单的数据。打印时打印全部数据正常,而打印当前数据或打印查询数据时,经常打印的都是空白的。请哪位朋友帮我查查错,谢谢了……
下面是全部的源码:
Private Sub Form_Load()
Set RS = New ADODB.Recordset '新建一个recordset
Set lsRS = New ADODB.Recordset
RS.CursorType = adOpenStatic
RS.CursorLocation = adUseClient
RS.LockType = adLockPessimistic
RS.Open "SELECT * FROM 用户管理 ORDER BY 姓名 ASC", Con
lsRS.CursorType = adOpenStatic
lsRS.CursorLocation = adUseClient
lsRS.LockType = adLockPessimistic
lsRS.Open "SELECT * FROM ls用户管理 ", Con
For i = 0 To 7
Set Text1(i).DataSource = RS
Text1(i).Locked = True
Next
Text1(0).DataField = "姓名"
Text1(1).DataField = "性别"
Text1(2).DataField = "年龄"
Text1(3).DataField = "联系方式"
Text1(4).DataField = "检查日期"
Text1(5).DataField = "视力检测"
Text1(6).DataField = "色觉检测"
Text1(7).DataField = "敏感度检测"
Set 用户_进口Grid.DataSource = RS
总数.Caption = RS.RecordCount
Text3.Text = ""
Text4.Text = ""
now_add = True
now_find = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
RS.MoveFirst
RS.Close
Do While lsRS.EOF = False
lsRS.Delete
lsRS.MoveNext
Loop
lsRS.Close
End Sub
Private Sub oplxr_Click()
Text4.Locked = False
Text4.SetFocus
Text3.Locked = True
Text3.Text = ""
End Sub
Private Sub opname_Click()
Text3.Locked = False
Text3.SetFocus
Text4.Locked = True
Text4.Text = ""
End Sub
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
Text3.Text = ""
Text4.Text = ""
opname.Value = False
oplxr.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 Text4.Locked = False Then
RS.Filter = "检查日期 LIKE ( '*" & Trim(Text4.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
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 7
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
old = RS.Bookmark
RS.AddNew
Text1(0).SelStart = 1
Text1(0).SelLength = Len(Text1(0).Text)
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 7
Text1(i).Locked = False
Next
For i = 0 To 6
Label8(i).Visible = True
Next
Else
If Text1(0).Text = "" Or Text1(4).Text = "" Then
MsgBox ("请填写带*号项")
Exit Sub
Else
With RS
.Fields("姓名") = Text1(0).Text
.Fields("性别") = Text1(1).Text
.Fields("年龄") = Text1(2).Text
.Fields("联系方式") = Text1(3).Text
.Fields("检查日期") = Text1(4).Text
.Fields("视力检测") = Text1(5).Text
.Fields("色觉检测") = Text1(6).Text
.Fields("敏感度检测") = Text1(7).Text
.Update
总数.Caption = .RecordCount
End With
End If
Toolbar1.Buttons(6).Caption = "添加"
Toolbar1.Buttons(7).Caption = "编辑"
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 7
Text1(i).Locked = True
Next
For i = 0 To 6
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 7
Text1(i).Locked = False
Next
Toolbar1.Buttons(6).Caption = "确定"
Toolbar1.Buttons(7).Caption = "取消"
For i = 1 To 5
Toolbar1.Buttons(i).Enabled = False
Next
For i = 0 To 6
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 = "编辑"
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 7
Text1(i).Locked = True
Next
For i = 0 To 6
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
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
Do While lsRS.EOF = False
lsRS.Delete
lsRS.MoveNext
Loop
lsRS.AddNew
For i = 0 To 7
lsRS.Fields(i) = RS.Fields(i)
Next
lsRS.Update
End Sub
Private Sub Toolbar1_ButtonMenuClick(ByVal ButtonMenu As MSComctlLib.ButtonMenu)
Select Case ButtonMenu.Index
Case 1
DataReport.DataMember = "all"
DataReport.Show
Case 2
DataReport.DataMember = "single"
DataReport.Show
End Select
End Sub