Report title help/IsLoaded ?

LaurieW

Registered User.
Local time
Today, 14:47
Joined
May 9, 2002
Messages
99
I have two forms where the user can choose what should appear on the report. For example, the user can select a date range or a date type. On these two forms there are several text boxes that fill using VB Code, depending on what is chosen on the form. One of these text boxes (txtReportTitle) holds the title that should appear on the report.

I can't figure out how to get this title on the report (I would like both forms to use the same report so I don't have to have two similar reports). Among many other things, I tried using the IsLoaded function, which I copied from the Northwind database. I put this in the Open event of the Report, but I get an error that says I "can't assign a value to this object."

Does anyone know how I can pass the title to the report from either form?

Here's the code I currently have on the report's Open event:

Private Sub Report_Open(Cancel As Integer)
If IsLoaded("Form_frmReportHiRise") = True Then
txtTitle = Form_frmReportHiRise.txtReportTitle
Else
txtTitle = Form_frmReportFamily.txtReportTitle
End If
End Sub

Thanks...Laurie
 
is the title on the report a text box?

If it is why not set its control source to
= Forms![frmReportHiRise]![txtReportTitle]
 
Sorry Laurie
i mis read your question

You could create a public variable to hold your value


Public MyreportTitle As String

then on the form that opens the report
MyReportTitle =me.TxtReportTitle

docmd.openreport YourReportname

Reports![reportName]![titlename]=MyReportTitle

That may do the job
 
Thanks for your response. I did as you suggested, but my title comes up blank on the report. Below is part of the code I have on my form button. On the report I have an unbound text box with the name "txtTitle". Any ideas why this isn't working? I checked the line MyReportTitle = Me.txtReportTitle in debug and it is filling in up to that point.

Thanks....Laurie

Private Sub cmdSelectedSite_Click()
On Error GoTo Err_cmdSelectedSite_Click

Dim stDocName As String

Me.Controls("txtSelectedSite") = Me.Controls("cboSelectedSite")
Me.Controls("txtDateFilter") = Me.Controls("cboDateType")
Me.Controls("txtReportTitle") = "Move In/Move Out Log For " & [Forms]![frmReportFamily]![cboSelectedSite] & ", " & [Forms]![frmReportFamily]![txtDateFilter] & " Between " & [Forms]![frmReportFamily]![txtStartDate] & " - " & [Forms]![frmReportFamily]![txtEndDate]
MyReportTitle = Me.txtReportTitle

stDocName = "rptAllData"

If cboSelectedSite = "All Family" Then
If txtDateFilter = "MO: Intent to Vacate" Then
DoCmd.OpenReport stDocName, acPreview, , "((tblAddress.Type) = 'Family' Or (tblAddress.Type) = 'Duplex' Or (tblAddress.Type) = 'Scat' Or (tblAddress.ProjectName) = 'Central Hi-Rise' Or (tblAddress.ProjectName) = 'Dunedin Hi-Rise' Or (tblAddress.ProjectName) = 'Mt. Airy Hi-Rise' And (tblMain.IntentToVacate) >= [Forms]![frmReportFamily]![txtStartDate] And (tblMain.IntentToVacate) <= [Forms]![frmReportFamily]![txtEndDate])"
Reports!rptAllData!txtTitle = MyReportTitle
 
try using the on print event for the report header to set
the title
me.txtTitle = MyReportTitle

i got the same as you (blank title) but when i used the on print event the title showed
 
Thanks! I will give that a try ... I was just about ready to give up on this one! Will let you know if it works...thanks again...Laurie
 
Yes, that did the trick! Thank you SO much. I had tried putting that code in other events on the report, but not the header. Whew!

Thank you again...Laurie
 

Users who are viewing this thread

Back
Top Bottom