使用vba代码,将记录添加到现有报告的详细信息部分
我正在尝试将记录添加到现有报告的详细信息部分。数据显示在设计视图中,但不显示在报告中。报告显示空白字段。另外,如果我希望每个字段都有黑色边框,如何在vba代码中执行此操作下面是我的代码: 将stDocName设置为字符串 dimdb作为数据库 将遥感器作为记录集 Dim rs2作为记录集 将sSQL设置为字符串 将fld调整为DAO.Field的记录集字段 Dim txtNew As Access.TextBox的TextBox控件 Dim rpt作为报告“保留报告对象” Dim lngTop“保持控制位置的最高值” Dim lngLeft As Long“保持控件位置的左侧值 昏暗的位置如长使用vba代码,将记录添加到现有报告的详细信息部分,vba,adodb,Vba,Adodb,我正在尝试将记录添加到现有报告的详细信息部分。数据显示在设计视图中,但不显示在报告中。报告显示空白字段。另外,如果我希望每个字段都有黑色边框,如何在vba代码中执行此操作下面是我的代码: 将stDocName设置为字符串 dimdb作为数据库 将遥感器作为记录集 Dim rs2作为记录集 将sSQL设置为字符串 将fld调整为DAO.Field的记录集字段 Dim txtNew As Access.TextBox的TextBox控件 Dim rpt作为报告“保留报告对象” Dim lngTop“
' initialise position variables
lngLeft = 0
lngTop = 0
'Create the report
'Set rpt = CreateReport
stDocName = "rptInvoice"
DoCmd.OpenReport stDocName, acViewDesign
sSQL = "Select SOWCode, SowDescription, Qty, Rate, SOWTotal from tbltmpInvoice"
' set properties of the Report
"与rpt
'宽度=8500
'.RecordSource=sSQL
"以
Set db = CurrentDb()
Set rs = db.OpenRecordset(sSQL)
'Count all records in the table tblCompany
rs.MoveLast
rs.MoveFirst
location = location + 900
阅读记录:
' Create corresponding label and text box controls for each field.
For Each fld In rs.Fields
' Create new text box control and size to fit data.
Set txtNew = CreateReportControl(stDocName, acTextBox, _
acDetail, , fld.Value, location, lngTop)
'txtNew.SizeToFit
'Relocate text field
location = location + 1000
Next
DoCmd.Close
' Increment top value for next control
'lngTop = lngTop + txtNew.Height + 25
stDocName = "rptInvoice"
DoCmd.OpenReport stDocName, acViewPreview
'DoCmd.Close
你应该重新格式化你的问题,一些代码显示为文本。你应该重新格式化你的问题,一些代码显示为文本。