Populate a combobox with Report Caption, not Report Name

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

Guest

Hi,

I found another post in which you helped the user with populating a combo
box with report names. This works great, except that my report names are
like 'rptReportName' and not very pretty. I have used the report.caption for
a more user-friendly report title/description. Is there a way that I can
capture the report's caption in the combobox, or do I need to change my
report names?

Thanks,

Arlene
 
Hi,

I found another post in which you helped the user with populating a combo
box with report names. This works great, except that my report names are
like 'rptReportName' and not very pretty. I have used the report.caption for
a more user-friendly report title/description. Is there a way that I can
capture the report's caption in the combobox, or do I need to change my
report names?

Thanks,

Arlene

I would suggest you create a table that includes the actual report
names as well as the name you want the user to see.
Then use that table to populate the combo box.

Select ReportTable.[ActualName], ReportTable.[UserFriendlyName] From
ReportTable Order by [UserFriendlyName];

Make the 1st column the bound column.
Set the Column count to 2
Set the Column Widths to 0";1"

Code the Combo box AfterUpdate event:
DoCmd.OpenReport Me!ComboName, acViewPreview
 
Hi Fred,

Thank you for responding so quickly. I had done that, but thought that
there must be a way to be able to populate the combobox without creating a
table and manually entering report names.

Thanks again,

Arlene

fredg said:
Hi,

I found another post in which you helped the user with populating a combo
box with report names. This works great, except that my report names are
like 'rptReportName' and not very pretty. I have used the report.caption for
a more user-friendly report title/description. Is there a way that I can
capture the report's caption in the combobox, or do I need to change my
report names?

Thanks,

Arlene

I would suggest you create a table that includes the actual report
names as well as the name you want the user to see.
Then use that table to populate the combo box.

Select ReportTable.[ActualName], ReportTable.[UserFriendlyName] From
ReportTable Order by [UserFriendlyName];

Make the 1st column the bound column.
Set the Column count to 2
Set the Column Widths to 0";1"

Code the Combo box AfterUpdate event:
DoCmd.OpenReport Me!ComboName, acViewPreview
 
swedbera said:
I found another post in which you helped the user with populating a combo
box with report names. This works great, except that my report names are
like 'rptReportName' and not very pretty. I have used the report.caption for
a more user-friendly report title/description. Is there a way that I can
capture the report's caption in the combobox, or do I need to change my
report names?


You can not retrieve a report's property unless the report
is open, either in design, preview or normal view.

You may want to consider creating a table with the report
name and caption as fields. Then this table can be used as
the combo box's RowSource. If you have a lot of report's,
you should also consider writing a procedure to automate
creating the records in this table.
 
That is a great idea, but is it possible to add the report's caption
programmatically?

Arlene
 
swedbera said:
That is a great idea, but is it possible to add the report's caption
programmatically?

Arlene


Like I said, you have to open the report (in design view) to
retrieve the property. Here's some code that you could use
(assuming you've already created the table and its two
fields):

Public Sub ReportListBuild()
Dim aoReport As AccessObject
Dim db As Database
Dim rs As Recordset

Set db = CurrentDb()
db.Execute "DELETE * FROM tblReportList"
Set rs = db.OpenRecordset("tblReportList")

For Each aoReport In CurrentProject.AllReports
DoCmd.OpenReport aoReport.Name, acViewDesign
With Reports(aoReport.Name)
rs.AddNew
rs!ReportName = .Name
rs!ReportCaption = .Caption
rs.Update
End With
DoCmd.Close acReport, aoReport.Name, acSaveNo
Next aoReport
rs.Close: Set rs = Nothing
Set db = Nothing
End Sub
 
Thank you Thank you!

This is exactly what I was trying to do, but couldn't get it right. I hope
that I can help others someday as you guys have helped me. We are lucky to
have you guys to turn to.

Arlene
 
Back
Top