Private Sub Command1_Click()
Dim mrc As ADODB.Recordset
Dim ms As ADODB.Recordset
Dim txtSQL As String
Dim txtSQL1 As String
Dim MsgText As String
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
'wdDoc.PageSetup.Orientation = wdOrientLandscape
Dim i, k, j As Integer
i = 0
If Option1(3) Or Option1(4) Or Option1(5) Then
If Option1(3) Then
txtSQL = "select * from 基本信息 where 学号='" & Text2.Text & "'"
txtSQL1 = "select * from 状态 where 学号='" & Text2.Text & "'"
ElseIf Option1(4) Then
txtSQL = "select * from 基本信息 where 姓名='" & Text2.Text & "'"
txtSQL1 = "select 状态.* from 状态,基本信息 where 状态.学号=基本信息.学号 and 姓名='" & Text2.Text & "'"
ElseIf Option1(5) Then
txtSQL = "select 基本信息.* from 基本信息,专业 where 专业.专业号=基本信息.专业号 and 专业 = '" & Text2.Text & "'"
txtSQL1 = "select 状态.* from 状态,基本信息,专业 where 专业.专业号=基本信息.专业号 and 状态.学号=基本信息.学号 and 专业 = '" & Text2.Text & "'"
Else
MsgBox "请选择条件"
End If
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF Then
MsgBox "没有符合要求的记录"
Else
n = 0
Set ms = ExecuteSQL(txtSQL1, MsgText)
Do While Not ms.EOF
ms.Fields(1) = "1"
ms.MoveNext
n = n + 1
Loop
ms.Close
Set wdApp = CreateObject("word.application")
wdApp.Visible = True
Set wdDoc = wdApp.Documents.add
wdDoc.Range.Tables.add wdDoc.Range, 360, 2
wdDoc.Tables(1).Range.Font.Size = 10
With wdDoc.Tables(1)
Do While Not mrc.EOF i = i + 1
.Cell(i, 1).Range.Text = "学号: " + mrc.Fields(0)
.Cell(i, 2).Range.Text = "姓名: " + mrc.Fields(1)
i = i + 1
.Cell(i, 1).Range.Text = mrc.Fields(12) & mrc.Fields(9)
mrc.MoveNext
Loop
mrc.Close
End With
End If
Else
MsgBox "请选择需要生成报表的记录"
End If
rc2 = rc2 + n
Label6.Caption = rc1
Label7.Caption = rc2
End Sub
怎么把这段的功能实现成为竖排的形式?
效果:档 计
案 算
寄 机
发 科
地 学
与
技
术
Dim mrc As ADODB.Recordset
Dim ms As ADODB.Recordset
Dim txtSQL As String
Dim txtSQL1 As String
Dim MsgText As String
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
'wdDoc.PageSetup.Orientation = wdOrientLandscape
Dim i, k, j As Integer
i = 0
If Option1(3) Or Option1(4) Or Option1(5) Then
If Option1(3) Then
txtSQL = "select * from 基本信息 where 学号='" & Text2.Text & "'"
txtSQL1 = "select * from 状态 where 学号='" & Text2.Text & "'"
ElseIf Option1(4) Then
txtSQL = "select * from 基本信息 where 姓名='" & Text2.Text & "'"
txtSQL1 = "select 状态.* from 状态,基本信息 where 状态.学号=基本信息.学号 and 姓名='" & Text2.Text & "'"
ElseIf Option1(5) Then
txtSQL = "select 基本信息.* from 基本信息,专业 where 专业.专业号=基本信息.专业号 and 专业 = '" & Text2.Text & "'"
txtSQL1 = "select 状态.* from 状态,基本信息,专业 where 专业.专业号=基本信息.专业号 and 状态.学号=基本信息.学号 and 专业 = '" & Text2.Text & "'"
Else
MsgBox "请选择条件"
End If
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF Then
MsgBox "没有符合要求的记录"
Else
n = 0
Set ms = ExecuteSQL(txtSQL1, MsgText)
Do While Not ms.EOF
ms.Fields(1) = "1"
ms.MoveNext
n = n + 1
Loop
ms.Close
Set wdApp = CreateObject("word.application")
wdApp.Visible = True
Set wdDoc = wdApp.Documents.add
wdDoc.Range.Tables.add wdDoc.Range, 360, 2
wdDoc.Tables(1).Range.Font.Size = 10
With wdDoc.Tables(1)
Do While Not mrc.EOF i = i + 1
.Cell(i, 1).Range.Text = "学号: " + mrc.Fields(0)
.Cell(i, 2).Range.Text = "姓名: " + mrc.Fields(1)
i = i + 1
.Cell(i, 1).Range.Text = mrc.Fields(12) & mrc.Fields(9)
mrc.MoveNext
Loop
mrc.Close
End With
End If
Else
MsgBox "请选择需要生成报表的记录"
End If
rc2 = rc2 + n
Label6.Caption = rc1
Label7.Caption = rc2
End Sub
怎么把这段的功能实现成为竖排的形式?
效果:档 计
案 算
寄 机
发 科
地 学
与
技
术
下面加一句
wdDoc.Tables(1).Range.Orientation = wdTextOrientationVerticalFarEast
看看