Adding reports to a combo box - caption not working.

odin1701

Registered User.
Local time
Today, 06:30
Joined
Dec 6, 2006
Messages
526
I'm trying to add a bunch of reports to a combo box. Here's the code:

Code:
Dim varReport As Variant
   
    With CurrentProject

        For Each varReport In .AllReports

            If Right(varReport.Name, 1) = "Z" Then

                cmbReport.AddItem varReport.Name
                                
            End If

        Next varReport

    End With

Problem is that the report names are not very end user friendly, and won't really be. I'm looking for a way to add the report's Caption to the combo as well, and tried using a 2 column combo and the following:

cmbReport.AddItem varReport.Name & ";" & varReport.Caption

This doesn't work though as I get an object doesn't support this property or method error.

Any help appreciated.
 
You will have to open the report in design view (or any other view you wish) to get the Caption.
 
You will have to open the report in design view (or any other view you wish) to get the Caption.

There is no other way?

So I have to hard code the names then....that's annoying.
 
I guess you could save it to a table and read it from the table. Update the table only if you make changes to a report name or delete or add new reports.
 
I guess you could save it to a table and read it from the table. Update the table only if you make changes to a report name or delete or add new reports.

That's just as bad as hard coding anyway...oh well.
 
It's not as bad. In fact it's not bad at all.

Run code to open each report (in design view) and save the report name and caption into the table. Afterwards you can run the same code to check for changes in the names or do it manually.
 

Users who are viewing this thread

Back
Top Bottom