467,087 Members | 1,292 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,087 developers. It's quick & easy.

Information not displaying on Access Report

I'm using VBA to dynamically add rows of textboxes to a Report, then
assign values to those textboxes. The values are definitely being
assigned as I can MsgBox them afterward and the values come up, but
they are NOT actually showing on the Report. Here's the code:

Private Sub Command0_Click()

Dim NewTextBox As TextBox

DoCmd.OpenReport "UserReport", acViewDesign

X = 1
BoxTop = 480
NextRow = 420

For r = #7/30/2008# To #8/7/2008#
'Day
Set NewTextBox =
Controls.Application.CreateReportControl("UserRepo rt", acTextBox)
With NewTextBox
.Name = "Day" & X
.Top = BoxTop
.Left = 120
.Width = 540
.Height = 300
.FontSize = 10
.FontName = "Arial"
.BorderStyle = fmBorderStyleSingle
.SpecialEffect = fmSpecialEffectFlat
End With

X = X + 1
BoxTop = BoxTop + NextRow

Next r

DoCmd.OpenReport "UserReport", acViewPreview

Y = 1

For r = #7/30/2008# To #8/7/2008#

ThsWkDy = Weekday(r)
Select Case (ThsWkDy)

Case 1
WkDy = "SUN"
Case 2
WkDy = "MON"
Case 3
WkDy = "TUE"
Case 4
WkDy = "WED"
Case 5
WkDy = "THU"
Case 6
WkDy = "FRI"
Case 7
WkDy = "SAT"
End Select
Reports("UserReport")("Day" & Y) = WkDy

Y = Y + 1

Next r

End Sub

The form comes up in Print Preview showing ONLY the Labels I've saved
it with for headers. How do I get the assigned values to show??
Aug 7 '08 #1
  • viewed: 1305
Share:
1 Reply
Several Things, Jeff

1 You shoud delare your variables. Use the Option Explicit at the top of
any module. Much more likely to pick up errors.
2 You can't ( so I believe) set the controsource on a report once it has
started printing.
3) Once you have created your report, you can't do it again unless you
dont save your report as the controls are already defined

Sorry I am usink AK2 so some of the border style commands aren't the same

Try

Option Compare Database
Option Explicit

Private Sub Command0_Click()

Dim NewTextBox As TextBox
Dim X As Integer
Dim BoxTop As Long, NextRow As Long, r As Long, Y As Long
Dim ThsWkDy As Integer
Dim WkDy As String
Dim FldName As String

DoCmd.OpenReport "Report1", acViewDesign

X = 1
BoxTop = 480
NextRow = 420

For r = #7/30/2008# To #8/7/2008#
'Day
Set NewTextBox = Controls.Application.CreateReportControl("Report1" ,
acTextBox)
With NewTextBox
.Name = "Day" & X
.Top = BoxTop
.Left = 120
.Width = 540
.Height = 300
.FontSize = 10
.FontName = "Arial"
.BorderStyle = 1 '*******
.SpecialEffect = 2 '**********
End With

X = X + 1
BoxTop = BoxTop + NextRow

Next r

'DoCmd.OpenReport "Report1", acViewPreview '***********

Y = 1

For r = #7/30/2008# To #8/7/2008#

ThsWkDy = Weekday(r)
Select Case (ThsWkDy)

Case 1
WkDy = "SUN"
Case 2
WkDy = "MON"
Case 3
WkDy = "TUE"
Case 4
WkDy = "WED"
Case 5
WkDy = "THU"
Case 6
WkDy = "FRI"
Case 7
WkDy = "SAT"
End Select

FldName = "Day" & Y

Reports!Report1.Controls(FldName).ControlSource = WkDy
'*************

Y = Y + 1

Next r

End Sub
Phil
<je***************@cox.comwrote in message
news:f8**********************************@j22g2000 hsf.googlegroups.com...
I'm using VBA to dynamically add rows of textboxes to a Report, then
assign values to those textboxes. The values are definitely being
assigned as I can MsgBox them afterward and the values come up, but
they are NOT actually showing on the Report. Here's the code:

Private Sub Command0_Click()

Dim NewTextBox As TextBox

DoCmd.OpenReport "UserReport", acViewDesign

X = 1
BoxTop = 480
NextRow = 420

For r = #7/30/2008# To #8/7/2008#
'Day
Set NewTextBox =
Controls.Application.CreateReportControl("UserRepo rt", acTextBox)
With NewTextBox
.Name = "Day" & X
.Top = BoxTop
.Left = 120
.Width = 540
.Height = 300
.FontSize = 10
.FontName = "Arial"
.BorderStyle = fmBorderStyleSingle
.SpecialEffect = fmSpecialEffectFlat
End With

X = X + 1
BoxTop = BoxTop + NextRow

Next r

DoCmd.OpenReport "UserReport", acViewPreview

Y = 1

For r = #7/30/2008# To #8/7/2008#

ThsWkDy = Weekday(r)
Select Case (ThsWkDy)

Case 1
WkDy = "SUN"
Case 2
WkDy = "MON"
Case 3
WkDy = "TUE"
Case 4
WkDy = "WED"
Case 5
WkDy = "THU"
Case 6
WkDy = "FRI"
Case 7
WkDy = "SAT"
End Select
Reports("UserReport")("Day" & Y) = WkDy

Y = Y + 1

Next r

End Sub

The form comes up in Print Preview showing ONLY the Labels I've saved
it with for headers. How do I get the assigned values to show??

Aug 8 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Russ | last post: by
3 posts views Thread by Mike Turco | last post: by
3 posts views Thread by Coll | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.