Public Sub SubCurPage(strPage As String) On Error Resume Next 'Rs.Requery Select Case strPage Case "One" If Rs.AbsolutePage <> 1 Then Rs.AbsolutePage = 1 End If Case "Pre" If Rs.AbsolutePage = 1 Or Rs.AbsolutePage = 2 Then MsgBox "您已经在第一页了!", vbOKOnly + vbExclamation, "提示" Exit Sub End If If Rs.AbsolutePage = -3 Then Rs.AbsolutePage = Rs.PageCount - 1
Else Rs.AbsolutePage = Rs.AbsolutePage - 2 End If Case "Next" If Rs.AbsolutePage = -3 Then MsgBox "您已经在最后一页了!", vbOKOnly + vbExclamation, "提示" Exit Sub End If Case "Last" Rs.AbsolutePage = Rs.PageCount End Select Me.VSFlexGrid1.Rows = 1 Dim i As Integer On Error Resume Next For i = 1 To Rs.PageSize If Rs.EOF Then SetHeader Exit Sub End If Me.VSFlexGrid1.Rows = Me.VSFlexGrid1.Rows + 1 Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 0) = Rs("ID") Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 1) = Rs("NumID") Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 2) = Rs("Name") If Not IsNull(Rs("JP")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 3) = Rs("JP") End If
If Not IsNull(Rs("BuWei")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 4) = Rs("BuWei") End If
If Not IsNull(Rs("KeBei")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 5) = Rs("KeBei") End If
If Not IsNull(Rs("XingZhi")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 6) = Rs("XingZhi") End If
If Not IsNull(Rs("WaitDealWith")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 7) = Rs("WaitDealWith") End If
If Not IsNull(Rs("WaitReName")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 8) = Rs("WaitReName") End If
If Not IsNull(Rs("UnSort")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 9) = Rs("UnSort") End If
If Not IsNull(Rs("NoFont")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 10) = Rs("NoFont") End If
If Not IsNull(Rs("UnShengMu")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 11) = Rs("UnShengMu") End If
If Not IsNull(Rs("Finished")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 12) = Rs("Finished") End If
If Not IsNull(Rs("HaveQuestion")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 13) = Rs("HaveQuestion") End If
If Not IsNull(Rs("ShouldHandOver")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 14) = Rs("ShouldHandOver") End If
If Not IsNull(Rs("Re")) Then Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 15) = Rs("Re") End If Rs.MoveNext Next i SetHeader If Rs.AbsolutePage = -3 Then frmMain.StatusBar1.Panels(1).Text = "共:" & Rs.PageCount & "页 当前页:" & Rs.PageCount Else frmMain.StatusBar1.Panels(1).Text = "共:" & Rs.PageCount & "页 当前页:" & Rs.AbsolutePage - 1 End If
Dim strSeled As String Dim X Dim rs_2 As New ADODB.Recordset Dim j As Integer
For j = 1 To Me.VSFlexGrid1.Rows - 1 If Trim(Me.VSFlexGrid1.TextMatrix(j, 4)) <> "" Then X = Split(Trim(Me.VSFlexGrid1.TextMatrix(j, 4)), ";") For i = 0 To UBound(X) lstrSql = "select name from BuWei Where ID=" & X(i) pPubobj.FunSelectField lstrSql, rs_2 If strSeled <> "" Then strSeled = strSeled & ";" strSeled = strSeled & Trim(rs_2("name"))
rs_2.Close Next i Me.VSFlexGrid1.TextMatrix(j, 4) = strSeled ' Me.txtBW = strSeled ' Me.txtBW.Tag = rs_1("BuWei") strSeled = "" End If
If Trim(Me.VSFlexGrid1.TextMatrix(j, 5)) <> "" Then X = Split(Trim(Me.VSFlexGrid1.TextMatrix(j, 5)), ";") For i = 0 To UBound(X) lstrSql = "select name from KeBei Where ID=" & X(i) pPubobj.FunSelectField lstrSql, rs_2 If strSeled <> "" Then strSeled = strSeled & ";" strSeled = strSeled & Trim(rs_2("name")) rs_2.Close
Next i ' Me.txtKB = strSeled Me.VSFlexGrid1.TextMatrix(j, 5) = strSeled strSeled = "" End If
If Trim(Me.VSFlexGrid1.TextMatrix(j, 6)) <> "" Then X = Split(Trim(Me.VSFlexGrid1.TextMatrix(j, 6)), ";") For i = 0 To UBound(X) lstrSql = "select name from Xingzhi Where ID=" & X(i) pPubobj.FunSelectField lstrSql, rs_2 If strSeled <> "" Then strSeled = strSeled & ";" strSeled = strSeled & Trim(rs_2("name")) rs_2.Close Next i Me.VSFlexGrid1.TextMatrix(j, 6) = strSeled strSeled = "" End If Set rs_2 = Nothing Next j End Sub
On Error Resume Next
'Rs.Requery
Select Case strPage
Case "One"
If Rs.AbsolutePage <> 1 Then
Rs.AbsolutePage = 1
End If
Case "Pre"
If Rs.AbsolutePage = 1 Or Rs.AbsolutePage = 2 Then
MsgBox "您已经在第一页了!", vbOKOnly + vbExclamation, "提示"
Exit Sub
End If
If Rs.AbsolutePage = -3 Then
Rs.AbsolutePage = Rs.PageCount - 1
Else
Rs.AbsolutePage = Rs.AbsolutePage - 2
End If
Case "Next"
If Rs.AbsolutePage = -3 Then
MsgBox "您已经在最后一页了!", vbOKOnly + vbExclamation, "提示"
Exit Sub
End If
Case "Last"
Rs.AbsolutePage = Rs.PageCount
End Select
Me.VSFlexGrid1.Rows = 1
Dim i As Integer
On Error Resume Next
For i = 1 To Rs.PageSize
If Rs.EOF Then
SetHeader
Exit Sub
End If
Me.VSFlexGrid1.Rows = Me.VSFlexGrid1.Rows + 1
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 0) = Rs("ID")
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 1) = Rs("NumID")
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 2) = Rs("Name")
If Not IsNull(Rs("JP")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 3) = Rs("JP")
End If
If Not IsNull(Rs("BuWei")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 4) = Rs("BuWei")
End If
If Not IsNull(Rs("KeBei")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 5) = Rs("KeBei")
End If
If Not IsNull(Rs("XingZhi")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 6) = Rs("XingZhi")
End If
If Not IsNull(Rs("WaitDealWith")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 7) = Rs("WaitDealWith")
End If
If Not IsNull(Rs("WaitReName")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 8) = Rs("WaitReName")
End If
If Not IsNull(Rs("UnSort")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 9) = Rs("UnSort")
End If
If Not IsNull(Rs("NoFont")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 10) = Rs("NoFont")
End If
If Not IsNull(Rs("UnShengMu")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 11) = Rs("UnShengMu")
End If
If Not IsNull(Rs("Finished")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 12) = Rs("Finished")
End If
If Not IsNull(Rs("HaveQuestion")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 13) = Rs("HaveQuestion")
End If
If Not IsNull(Rs("ShouldHandOver")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 14) = Rs("ShouldHandOver")
End If
If Not IsNull(Rs("Re")) Then
Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.BottomRow, 15) = Rs("Re")
End If
Rs.MoveNext
Next i
SetHeader
If Rs.AbsolutePage = -3 Then
frmMain.StatusBar1.Panels(1).Text = "共:" & Rs.PageCount & "页 当前页:" & Rs.PageCount
Else
frmMain.StatusBar1.Panels(1).Text = "共:" & Rs.PageCount & "页 当前页:" & Rs.AbsolutePage - 1
End If
Dim strSeled As String
Dim X
Dim rs_2 As New ADODB.Recordset
Dim j As Integer
For j = 1 To Me.VSFlexGrid1.Rows - 1
If Trim(Me.VSFlexGrid1.TextMatrix(j, 4)) <> "" Then
X = Split(Trim(Me.VSFlexGrid1.TextMatrix(j, 4)), ";")
For i = 0 To UBound(X)
lstrSql = "select name from BuWei Where ID=" & X(i)
pPubobj.FunSelectField lstrSql, rs_2
If strSeled <> "" Then strSeled = strSeled & ";"
strSeled = strSeled & Trim(rs_2("name"))
rs_2.Close
Next i
Me.VSFlexGrid1.TextMatrix(j, 4) = strSeled
' Me.txtBW = strSeled
' Me.txtBW.Tag = rs_1("BuWei")
strSeled = ""
End If
If Trim(Me.VSFlexGrid1.TextMatrix(j, 5)) <> "" Then
X = Split(Trim(Me.VSFlexGrid1.TextMatrix(j, 5)), ";")
For i = 0 To UBound(X)
lstrSql = "select name from KeBei Where ID=" & X(i)
pPubobj.FunSelectField lstrSql, rs_2
If strSeled <> "" Then strSeled = strSeled & ";"
strSeled = strSeled & Trim(rs_2("name"))
rs_2.Close
Next i
' Me.txtKB = strSeled
Me.VSFlexGrid1.TextMatrix(j, 5) = strSeled
strSeled = ""
End If
If Trim(Me.VSFlexGrid1.TextMatrix(j, 6)) <> "" Then
X = Split(Trim(Me.VSFlexGrid1.TextMatrix(j, 6)), ";")
For i = 0 To UBound(X)
lstrSql = "select name from Xingzhi Where ID=" & X(i)
pPubobj.FunSelectField lstrSql, rs_2
If strSeled <> "" Then strSeled = strSeled & ";"
strSeled = strSeled & Trim(rs_2("name"))
rs_2.Close
Next i
Me.VSFlexGrid1.TextMatrix(j, 6) = strSeled
strSeled = ""
End If
Set rs_2 = Nothing
Next j
End Sub
在屬性上注意﹕pagesize,AbsolutePage,還有個屬性是什么﹐不記得了﹐
因為當時試的時候只用了這2個屬性。用rs1.PageSize = n(n為數字)來定義每一頁顯示n筆資料。
用AbsolutePage來定義在多少葉面。
比如AbsolutePage=1,則是在首葉面,用一個變量來定義比如 rs1.AbsolutePage = pageNo,如果是第一葉﹐則pageNo = 1﹐
下一葉pageNo = pageNo + 1﹐上葉為pageNo = pageNo - 1﹐
尾葉則是pageNo = rs1.PageCount
在MSFlexGrid1顯示中﹐和原來顯示是一樣的﹐則是從數據庫中調出循環為
到1 to rs1.pagesize.OK,不想寫代碼給你﹐因為﹐畢竟你得自己試下﹐對你有用﹐理解才行。