Display a report title by what criteria was chosen

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form using an Option Group box that calls the same report and
displays the records that the user has chosen. I have 4 choices for them to
choose from and then the report is displayed filtered with the records that
they chose. What I want to do is have the report title display what kind of
report they chose. How do I create a variable that will show up on the
report?

Thanks in advance and please explain the steps for me as I am learning Access

June
 
June said:
I have a form using an Option Group box that calls the same report and
displays the records that the user has chosen. I have 4 choices for them to
choose from and then the report is displayed filtered with the records that
they chose. What I want to do is have the report title display what kind of
report they chose. How do I create a variable that will show up on the
report?

Use a text box in the report header section. Set the text
box's Control Source property to refer to the form's Option
Group to get the option number. You haven't explained how
you wabt to translate the number to something more
meaningful to your users, so, at this point I can only say
how to get the number:

=Forms![the form name].[the option group name]
 
I want to display a title that corresponds with the option that they chose.
The would be, "Filed Documents, Released Documents, Filed Media, All
Documents & Media"

I want to capture the option that they chose and have it select the title
for the report.

Thanks,

June


Marshall Barton said:
June said:
I have a form using an Option Group box that calls the same report and
displays the records that the user has chosen. I have 4 choices for them to
choose from and then the report is displayed filtered with the records that
they chose. What I want to do is have the report title display what kind of
report they chose. How do I create a variable that will show up on the
report?

Use a text box in the report header section. Set the text
box's Control Source property to refer to the form's Option
Group to get the option number. You haven't explained how
you wabt to translate the number to something more
meaningful to your users, so, at this point I can only say
how to get the number:

=Forms![the form name].[the option group name]
 
I figured it out.

Option box was called get_doc
The string passed with the report title was called stReportName. I had to
make it public for the report to get it. I suppose I could have tried
passing get_doc.

For the button that calls the report I have created code for the On Click.
I entered a Case for each of the 4 options from the get_doc option box which
assigns a title name to the public variable stReportName. On the report I
have a text box where my title will be and in the properties Control Source I
have:
=[Forms]![Frm_Documents].[stReportName].

May not be the best way to do it but it works and I am happy. See code for
report button below. I am adding this to help others who maybe trying to
figure this out.

Thanks for you help because you did help me work through it I just didn't
give you enough information.

Thanks and keep up the good work,

June

Report button code:
Option Explicit
Public stReportName As String

Private Sub Get_Documents_Click()
On Error GoTo Err_Get_Documents_Click

Dim stDocName As String

' For each report select the correct title to display from the user's
selection
Select Case get_doc
Case 5
stReportName = "GPS Subsystem Released Documents"
Case 6
stReportName = "Locally Filed Documents"
Case 7
stReportName = "Locally Stored Media"
Case 8
stReportName = "All Documents and Media"
End Select

'If the user wants to see all of the records then change get_doc to an "*" so
' that all records are retrieved and displayed in the report. Otherwise, just
' retrieve the records that match the request.

If get_doc = "8" Then get_doc = "*"
stDocName = "Rpt_Documents"
DoCmd.OpenReport stDocName, acPreview

Exit_Get_Documents_Click:
Exit Sub

Err_Get_Documents_Click:
MsgBox Err.Description
Resume Exit_Get_Documents_Click

End Su
________________________________________________________________________________________________________________________________________
 
Yes you did!

Actually, the code you're using is an excellent way to do
this and what I would have recommended.

Keep up the good work.
--
Marsh
MVP [MS Access]


I figured it out.

Option box was called get_doc
The string passed with the report title was called stReportName. I had to
make it public for the report to get it. I suppose I could have tried
passing get_doc.

For the button that calls the report I have created code for the On Click.
I entered a Case for each of the 4 options from the get_doc option box which
assigns a title name to the public variable stReportName. On the report I
have a text box where my title will be and in the properties Control Source I
have:
=[Forms]![Frm_Documents].[stReportName].

May not be the best way to do it but it works and I am happy. See code for
report button below. I am adding this to help others who maybe trying to
figure this out.

Thanks for you help because you did help me work through it I just didn't
give you enough information.

Report button code:
Option Explicit
Public stReportName As String

Private Sub Get_Documents_Click()
On Error GoTo Err_Get_Documents_Click

Dim stDocName As String

' For each report select the correct title to display from the user's
selection
Select Case get_doc
Case 5
stReportName = "GPS Subsystem Released Documents"
Case 6
stReportName = "Locally Filed Documents"
Case 7
stReportName = "Locally Stored Media"
Case 8
stReportName = "All Documents and Media"
End Select

'If the user wants to see all of the records then change get_doc to an "*" so
' that all records are retrieved and displayed in the report. Otherwise, just
' retrieve the records that match the request.

If get_doc = "8" Then get_doc = "*"
stDocName = "Rpt_Documents"
DoCmd.OpenReport stDocName, acPreview

Exit_Get_Documents_Click:
Exit Sub

Err_Get_Documents_Click:
MsgBox Err.Description
Resume Exit_Get_Documents_Click

End Sub
________________________________________________________________________________________________________________________________________

June said:
I have a form using an Option Group box that calls the same report and
displays the records that the user has chosen. I have 4 choices for them to
choose from and then the report is displayed filtered with the records that
they chose. What I want to do is have the report title display what kind of
report they chose. How do I create a variable that will show up on the
report?
 
Back
Top