esilva002
09-27-2010, 08:01 AM
Hi,
I have a report that I set values for on runtime. These values fome from a public variable that I set on the previous form. I have done this two different ways and recieve two different errors.
Procedure 1:
Dim BegDate As Date
Dim EndDate As Date
Dim NumberofDays As Integer
Dim ctr As Integer
BegDate = Me.cboYear.Value & "-" & Me.cboMonth.Value & "-" & "01"
EndDate = DateSerial(Year(BegDate), Month(BegDate) + 1, 0)
NumberofDays = DateDiff("d", BegDate, EndDate) + 1
Do Until ctr = NumberofDays
pArray1(ctr) = DateAdd("d", ctr, BegDate)
DoCmd.OpenReport "rptJudicialCalendarBLANK1", acViewPreview
With Reports!rptJudicialCalendarBLANK1
.txtInfo.Text = "SCHEDULED COURT ROOM TIME FOR " & pArray1(ctr)
.txtFooter.Text = pArray1(ctr)
End With
DoCmd.Close acReport, "rptJudicialCalendarBLANK1", acSaveYes
DoCmd.OpenReport "rptJudicialCalendarBLANK1", acViewNormal
ctr = ctr + 1
Loop
Procedure 1 finds the begining and ending of the selected month. Then finds the number of days in that month. Then I build my array with the first date, second date, and so on. Then open my report and set values using the with command. Close it and then print out the report all within a loop. So within September I should have 30 printouts of the same report, the only difference is the date.
THE PROBLEM WITH PROCEDURE 1:
When I set the .txtInfo.Text within my With Statement I get the Run-time error '2185': You can't reference a property or method for a control unless the control has the focus.
Procedure 2:
Dim BegDate As Date
Dim EndDate As Date
Dim NumberofDays As Integer
Dim ctr As Integer
BegDate = Me.cboYear.Value & "-" & Me.cboMonth.Value & "-" & "01"
EndDate = DateSerial(Year(BegDate), Month(BegDate) + 1, 0)
NumberofDays = DateDiff("d", BegDate, EndDate) + 1
Do Until ctr = NumberofDays
pArray1(ctr) = DateAdd("d", ctr, BegDate)
DoCmd.OpenReport "rptJudicialCalendarBLANK1", acViewNormal, , , , pArray1(ctr)
ctr = ctr + 1
Loop
Procudure 2 finds the number of days same as procudure 1 but this time I push the array value through the report.
The report code looks like this:
Private Sub Report_Activate()
If Not IsNull(Me.OpenArgs) Then
Me.txtInfo = "SCHEDULED COURT ROOM TIME FOR " & Me.OpenArgs
Me.txtFooter = Me.OpenArgs
End If
End Sub
Private Sub Report_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then
Me.txtInfo.Value = "SCHEDULED COURT ROOM TIME FOR " & Me.OpenArgs
Me.txtFooter.Value = Me.OpenArgs
End If
End Sub
I have the same code in Report_Open and Report_Activate. I found code on the internet that said to push values through the Report_Activate event. But I found that through debugging that Report_Activate isn't even getting hit. So, I tossed that same code in the Report_Open event.
THE PROBLEM WITH PROCEDURE 2:
In my Reprt_Open when I try and assign Me.txtInfo.Value to the variable. It gives me the Run-time error '2448' You can't assign a value to the object.
Please Help!
I have a report that I set values for on runtime. These values fome from a public variable that I set on the previous form. I have done this two different ways and recieve two different errors.
Procedure 1:
Dim BegDate As Date
Dim EndDate As Date
Dim NumberofDays As Integer
Dim ctr As Integer
BegDate = Me.cboYear.Value & "-" & Me.cboMonth.Value & "-" & "01"
EndDate = DateSerial(Year(BegDate), Month(BegDate) + 1, 0)
NumberofDays = DateDiff("d", BegDate, EndDate) + 1
Do Until ctr = NumberofDays
pArray1(ctr) = DateAdd("d", ctr, BegDate)
DoCmd.OpenReport "rptJudicialCalendarBLANK1", acViewPreview
With Reports!rptJudicialCalendarBLANK1
.txtInfo.Text = "SCHEDULED COURT ROOM TIME FOR " & pArray1(ctr)
.txtFooter.Text = pArray1(ctr)
End With
DoCmd.Close acReport, "rptJudicialCalendarBLANK1", acSaveYes
DoCmd.OpenReport "rptJudicialCalendarBLANK1", acViewNormal
ctr = ctr + 1
Loop
Procedure 1 finds the begining and ending of the selected month. Then finds the number of days in that month. Then I build my array with the first date, second date, and so on. Then open my report and set values using the with command. Close it and then print out the report all within a loop. So within September I should have 30 printouts of the same report, the only difference is the date.
THE PROBLEM WITH PROCEDURE 1:
When I set the .txtInfo.Text within my With Statement I get the Run-time error '2185': You can't reference a property or method for a control unless the control has the focus.
Procedure 2:
Dim BegDate As Date
Dim EndDate As Date
Dim NumberofDays As Integer
Dim ctr As Integer
BegDate = Me.cboYear.Value & "-" & Me.cboMonth.Value & "-" & "01"
EndDate = DateSerial(Year(BegDate), Month(BegDate) + 1, 0)
NumberofDays = DateDiff("d", BegDate, EndDate) + 1
Do Until ctr = NumberofDays
pArray1(ctr) = DateAdd("d", ctr, BegDate)
DoCmd.OpenReport "rptJudicialCalendarBLANK1", acViewNormal, , , , pArray1(ctr)
ctr = ctr + 1
Loop
Procudure 2 finds the number of days same as procudure 1 but this time I push the array value through the report.
The report code looks like this:
Private Sub Report_Activate()
If Not IsNull(Me.OpenArgs) Then
Me.txtInfo = "SCHEDULED COURT ROOM TIME FOR " & Me.OpenArgs
Me.txtFooter = Me.OpenArgs
End If
End Sub
Private Sub Report_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then
Me.txtInfo.Value = "SCHEDULED COURT ROOM TIME FOR " & Me.OpenArgs
Me.txtFooter.Value = Me.OpenArgs
End If
End Sub
I have the same code in Report_Open and Report_Activate. I found code on the internet that said to push values through the Report_Activate event. But I found that through debugging that Report_Activate isn't even getting hit. So, I tossed that same code in the Report_Open event.
THE PROBLEM WITH PROCEDURE 2:
In my Reprt_Open when I try and assign Me.txtInfo.Value to the variable. It gives me the Run-time error '2448' You can't assign a value to the object.
Please Help!