Thanks very much, Tom.
First I am so sorry that I was so stupid as to post only the case statement.
This is a private sub button click, form class module and all the code is
posted at the end of my comments.
I think what you are saying is that when calling the report from a class
module, I am not yet able to change the value of an unbound field on a report
that is not yet open ??? So by setting the value on a form field that is
read from the report that will solve this. Am I correct, or close maybe??
Now here is my new thought, I already have 2 fields on the form that pretty
much contain what I want printed in the report. I'll try to explain this
clearly, but no guarantees. On the Form I have a group option, in the group
option I have 3 options, and each option has a label. The option box is used
to select the parameters for one report or select a different report. If I
can use the caption of the option label as the value in text45, that would
solve everything. And, Yes I will rename text45 to something more
descriptive once I get everything working.
I've got this working but if there's way that I could have used the option
labels better, please let me know.
Private Sub cmd_Prv_RPT_Click()
On Error GoTo Err_cmd_Prv_RPT_Click
Dim stDocName, stFilter As String
Select Case Me.Opt_ReportFilter.Value
Case 1
stDocName = "r_DB Change Log"
stFilter = "[DB Change Log].priority ='0'"
Me.[RptLbl_Source] = Me.Label82.Caption
Case 2
stDocName = "r_DB Change Log"
stFilter = "([DB Change Log].priority <>'0' OR [DB Change
Log].priority is null) and [DB Change Log].completed is null"
Me.[RptLbl_Source] = Me.Label84.Caption
Case 3
stDocName = "r_DB Change Log - Implemented"
stFilter = ""
Me.[RptLbl_Source] = Me.Label86.Caption
End Select
DoCmd.OpenReport stDocName, acPreview, , stFilter
Exit_cmd_Prv_RPT_Click:
Exit Sub
======================================
Tom Wickerath said:
It's not real clear to me where your Select Case....End Select code is found.
Is it in a form's class module? If so, try setting an unbound text box to
whatever string you want. This text box will have it's visible property set
to No, so that it is not displayed on the form. For example:
Me.txtFilter = "Priority = 0"
Then, in the report's text box (presumably "text45", based on your
example--please do give this text box a more reasonable name), you set an
expression to point to the open form. For example:
= [Forms]![Frm_ReportFilter]![txtFilter]
Of course, the Frm_ReportFilter form must be open, and the txtFilter text
box should have a value stuffed into it, by the time your report starts to
open.
Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
MVP - WannaB said:
I am trying to populate the value of an unbound text filed on a report, but I
am doing somethign a little wrong, because it doesn't recognize the name of
the text field.. Here is my code, I'm msure someone here will post this it
is so simple, but not for me - today..
Select Case Me.Frm_ReportFilter.Value
Case 1
stFilter = "[DB Change Log].priority ='0'"
[rDB Change Log- Priority 0].text45 = "Priority = 0"
Case 2
stFilter = "([DB Change Log].priority <>'0' OR [DB Change
Log].priority is null) and [DB Change Log].completed is null"
[rDB Change Log- Priority 0].text45 = "Priority <> 0"
End Select
Thanks you, I really appreciate your help !!!!