好的,我对构建访问报告的VBA语法有一些疑问。
我知道以下函数可以插入信息 CreateReportControl 功能,删除信息 DeleteReportControl ,甚至可以使用部分修改部分
EX: rpt.section(acDetail).Height = 0 。
我想知道如何切换页眉和页脚,而不仅仅是将Visable设置为False。我想要它,所以它在设计视图中无法看到。
如何在Vba中复制报告并为其指定新名称/将子报告添加到主报告并移动它的位置。或者至少复制它并保持打开,因为我有一个代码重命名它,如下所示:
Public Function GetUniqueReportName() As String
Dim intCounter As Integer
Dim blnIsUnique As Boolean
Dim rpt As Object
For intCounter = 1 To 256
GetUniqueReportName = "SubReport_" & Format(intCounter, "0000")
blnIsUnique = True
For Each rpt In CurrentProject.AllReports
If rpt.Name = GetUniqueReportName Then blnIsUnique = False
Next
If blnIsUnique Then Exit Function
Next
GetUniqueReportName = ""
End Function
还有更多的功能可以帮助我通过VBA构建Access报告,你不必解释他们做什么我只是想知道它们是什么所以我可以直接搜索它们,因为那里网上有很多关于如何做到这一点的信息。
所有这些信息都会有很大帮助,而且我假设很多其他人都可以使用这些信息,而且这个信息并不多。提前致谢! :)如果您无法回答所有问题,那么此时的任何信息都是奖励。
答案 0 :(得分:3)
III。这将通过调用rptCreateTmpReportSimple()来创建rptTmp:
Function rptCreateTmpReportSimple()
'
Dim lLeft As Long, lTop As Long, lWidth As Long, lHeight As Long
'
Dim strFld As String, strRecordSource As String
Dim strRpt As String
'
Dim rpt As Access.Report
Dim ctl As Access.control
'
strRecordSource = "MyTableName"
strRpt = "rptTmp"
'
Set rpt = Application.CreateReport
'
rpt.visible = False
'
' define report properties, unit is in twips.
'
rpt.RecordSource = strRecordSource
rpt.caption = "Special Report"
'
rpt.DefaultView = acPreview
rpt.Width = 9870
'
rpt.visible = True
'
' save it with a name:
'
DoCmd.Save acDefault, strRpt
'
' create a textbox for each field:
'
strFld = "FieldName1"
lLeft = 100
lTop = 50
lWidth = 2000
lHeight = 250
'
Set ctl = Application.CreateReportControl(strRpt, acTextBox, _
acDetail, , strFld, lLeft, lTop, lWidth, lHeight)
ctl.Name = strFld
ctl.Fontsize = 8
'
' Create other controls...
'...
'
DoCmd.Close acReport, strRpt, acSaveYes
'
' close ADO objects:
'
Set ctl = Nothing
Set rpt = Nothing
'
rptCreateTmpReportSimple = strRpt
'
End Function
对于你的问题:
予。您无法删除页眉和页脚,但可以将它们缩小到0高度。
II。将rptTmp复制到rptTmp2:
DoCmd.CopyObject , "rptTmp2", acReport, "rptTmp"