不好意思,刚才着急,发错了!提示信息是:查询错误 下标越界!
代码如下:
Private Sub Command7_Click()
If Trim(Me.Text12) = "" Then
MsgBox "请选择查询的条件!", vbOKOnly + vbExclamation, "警告!"
Else
Call setSQL
Call createlist(query)
End If
End Sub
Private Sub setSQL()
Dim query As String
Dim rs As New ADODB.Recordset
If Check1.Value = vbChecked Then
query = "select * from yuangong_info where 姓名='" & Trim(Me.Text12) & "'"
Set rs = TransactSQL(query)
If rs.EOF = True Then
MsgBox "设备编号不存在!请重新输入!", vbOKOnly + vbExclamation, "警告"
Text12.SetFocus
Text12.Text = ""
End If
End If
End Sub
Private Sub createlist(sql)
Dim rs As New ADODB.Recordset
Dim i As Integer
Dim rsGird As MSFlexGrid
With rsGrid '设置表头
.TextMatrix(0, 0) = "序号"
.TextMatrix(0, 1) = "职工编号"
.TextMatrix(0, 2) = "姓名"
.TextMatrix(0, 3) = "性别"
.TextMatrix(0, 4) = "出生年月"
.TextMatrix(0, 5) = "技术职称"
.TextMatrix(0, 6) = "职称时间"
.TextMatrix(0, 7) = "学历"
.TextMatrix(0, 8) = "工作时间"
.TextMatrix(0, 9) = "所属部门"
.TextMatrix(0, 10) = "工资级别"
.TextMatrix(0, 11) = "现任职务"
.TextMatrix(0, 12) = "毕业院校"
.TextMatrix(0, 13) = "个人简历"
For i = 0 To 13 '设置所有表格对齐方式
.ColAlignment(i) = 1
Next i
.ColWidth(0) = 500
.ColWidth(1) = 900
.ColWidth(2) = 700
.ColWidth(3) = 500
.ColWidth(4) = 1000
.ColWidth(5) = 1200
.ColWidth(6) = 1000
.ColWidth(7) = 600
.ColWidth(8) = 1000
.ColWidth(9) = 1000
.ColWidth(10) = 1000
.ColWidth(11) = 1400
.ColWidth(12) = 1400
.ColWidth(13) = 1400
End With
Set rs = TransactSQL(sql)
If rs.EOF = False Then
With rsGrid
.Rows = 1
While Not rs.EOF
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = rs(0)
.TextMatrix(.Rows - 1, 1) = rs(1)
.TextMatrix(.Rows - 1, 2) = rs(2)
.TextMatrix(.Rows - 1, 3) = rs(3)
.TextMatrix(.Rows - 1, 4) = rs(4)
.TextMatrix(.Rows - 1, 5) = rs(5)
.TextMatrix(.Rows - 1, 6) = rs(6)
.TextMatrix(.Rows - 1, 7) = rs(7)
.TextMatrix(.Rows - 1, 8) = rs(8)
.TextMatrix(.Rows - 1, 9) = rs(9)
.TextMatrix(.Rows - 1, 10) = rs(10)
.TextMatrix(.Rows - 1, 11) = rs(11)
.TextMatrix(.Rows - 1, 12) = rs(12)
.TextMatrix(.Rows - 1, 13) = rs(13)
rs.MoveNext
Wend
End With
rs.Close
End If
End Sub