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.OpenRepor t "Report1", acViewDesign
X = 1
BoxTop = 480
NextRow = 420
For r = #7/30/2008# To #8/7/2008#
'Day
Set NewTextBox = Controls.Applic ation.CreateRep ortControl("Rep ort1",
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.OpenRepo rt "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(FldNa me).ControlSour ce = WkDy
'*************
Y = Y + 1
Next r
End Sub
Phil
<je************ ***@cox.comwrot e in message
news:f8******** *************** ***********@j22 g2000hsf.google groups.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.OpenRepor t "UserReport ", acViewDesign
X = 1
BoxTop = 480
NextRow = 420
For r = #7/30/2008# To #8/7/2008#
'Day
Set NewTextBox =
Controls.Applic ation.CreateRep ortControl("Use rReport", acTextBox)
With NewTextBox
.Name = "Day" & X
.Top = BoxTop
.Left = 120
.Width = 540
.Height = 300
.FontSize = 10
.FontName = "Arial"
.BorderStyle = fmBorderStyleSi ngle
.SpecialEffect = fmSpecialEffect Flat
End With
X = X + 1
BoxTop = BoxTop + NextRow
Next r
DoCmd.OpenRepor t "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("UserRe port")("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??