Results 1 to 5 of 5

Thread: List all the reports in a VB6 Project

  1. #1

    Thread Starter
    New Member soulbriski's Avatar
    Join Date
    Jul 2006
    Location
    Manchester
    Posts
    6

    List all the reports in a VB6 Project

    Hi

    Does anyone know how to itterate the reports collection in a VB6 project?

    I am trying to present a list to the user, of reports that are available in the application but there doen't seem to be the opportunity to itterate the reports collection as you would any other object.

    For instance, If the following code would work, there would be no problem.

    VB Code:
    1. Dim rpt as DataReport 'This is OK
    2.  
    3. For Each rpt in <ThisProject>.DataReports 'This doesnt exist
    4.  
    5. [INDENT]lstReports.AddItem rpt.Name[/INDENT]
    6. Next rpt

    If this worked the user could then select the report name from the list, choose to preview it or not and specify criteria like date ranges etc

    Is it possible to achieve what I'm trying to?

    Many thanks

  2. #2
    Lively Member
    Join Date
    Mar 2006
    Posts
    94

    Re: List all the reports in a VB6 Project

    Quote Originally Posted by soulbriski
    Hi

    Does anyone know how to itterate the reports collection in a VB6 project?

    I am trying to present a list to the user, of reports that are available in the application but there doen't seem to be the opportunity to itterate the reports collection as you would any other object.

    For instance, If the following code would work, there would be no problem.

    VB Code:
    1. Dim rpt as DataReport 'This is OK
    2.  
    3. For Each rpt in <ThisProject>.DataReports 'This doesnt exist
    4.  
    5. [INDENT]lstReports.AddItem rpt.Name[/INDENT]
    6. Next rpt

    If this worked the user could then select the report name from the list, choose to preview it or not and specify criteria like date ranges etc

    Is it possible to achieve what I'm trying to?

    Many thanks
    OK without checking this and without my reference books handy, this is how I remember doing it.

    VB Code:
    1. dim x as integer
    2. for x = 0 to Reports.Count
    3.     lstReports.AddItem Reports.Item(x).Name
    4. next x
    Energy can be neither created not destroyed. It can only be wasted.

    Red Green

  3. #3

    Thread Starter
    New Member soulbriski's Avatar
    Join Date
    Jul 2006
    Location
    Manchester
    Posts
    6

    Re: List all the reports in a VB6 Project

    Thanks for responding

    Reports.Count cannot be referenced. VB thinks 'Reports' is an undeclared variable.

    Also

    DataReport.Count doesn't work, same reason!

    I can't think of a way of doing this but it comes up in many of my apps so i really would like to master it

  4. #4
    Lively Member
    Join Date
    Mar 2006
    Posts
    94

    Re: List all the reports in a VB6 Project

    Quote Originally Posted by soulbriski
    Thanks for responding

    Reports.Count cannot be referenced. VB thinks 'Reports' is an undeclared variable.

    Also

    DataReport.Count doesn't work, same reason!

    I can't think of a way of doing this but it comes up in many of my apps so i really would like to master it
    My apologies that was for Access 2002. It seems that there is no collection for datareports in VB6. You will probably have to think of another way to track reports. The most likely way I would think would be a table and you load the list from the table.

    Good Luck anyways Sorry I wasn't any help.
    Energy can be neither created not destroyed. It can only be wasted.

    Red Green

  5. #5

    Thread Starter
    New Member soulbriski's Avatar
    Join Date
    Jul 2006
    Location
    Manchester
    Posts
    6

    Re: List all the reports in a VB6 Project

    Thanks anyway KG

    I will carry on doing it the same way as i always do but there must be a better way.

    I am leaving this thread open in case anyone comes across it and can help

    By the way, the way i do it at present is as you mention with a table containing the report name and a friendly name. the user sees the friendly name but then the corresponding ReportName is run when they select the friendly name from the list or other GUI. The problem with this method is that the table may not be consistent with the reports in the project if for instance i have built a new report and not added it to the table.

    Itterating the Reports collection is the only way to do it properly but I'm dammed if i can find out how to

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width