Results 1 to 3 of 3

Thread: VB 6 Reports problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    1

    Question VB 6 Reports problem

    Hi,
    This is my first post on VBForums. I am trying to run some reports using the reports tool in VB6 this is the only i have to use.(no Crystal Reports). I am able to make reports pulling data from my Oracle database, but I can only get data from one table. I want to be able to pull information from multiple tables from the database, and I have no clue how to do this.
    Anyone have any ideas or links to information on this?

    Thanks
    Eric

  2. #2

    Re: VB 6 Reports problem

    Hi Eric,

    The Reporting tool that comes with VB 6 doesn't allow polling for multiple tables. However there is a workaround to this depending on the specific needs of your report.

    For example you could use a TempTable (worktable) where in VB you perform multiple "INSERT INTO FROM SELECT FROM <TABLENAME>" statement for each data you want (provided the data structure is the same).... ALl into that work table (with a field called table name so you can group by that field in your report. You could also perform a SELECT * FROM <Table1>, <Table2>, <TableN> where COnditions would also get you data from more than one table. Really depends on your needs. So, I could give you much more details and examples if I knew the following.

    - The Tables you need data from (field definition would be a big plus ;-).
    - What you need done with the information
    - What kind of output you expect (a description of the fields you used to design the report).

    Then we'll see what we can do :-)

    Hope this helps
    When they say it can't be done, THAT's when they call me ;-)

    MystikShadows
    JC-Hosting.net

  3. #3
    Fanatic Member vb_dba's Avatar
    Join Date
    Jun 2001
    Location
    Somewhere aloft between the real world and insanity
    Posts
    1,016

    Re: VB 6 Reports problem

    You should be able to generate a Recordset using an SQL statement that joins the tables together, then in the DataReport_Initialize() event, set the datasource of the report to the Recordset:
    Code:
    Private Sub DataReport_Initialize()
        Dim oRS  As Recordset
        Dim sSql  As String
    
        sSql = "Select a.Field1, a.Field2, b.Field3, b.Field 4 " & _
               "From Table1 a Inner Join Table2 b On a.Field1 = b.Field1 " & _
               "Where a.Field2 = 'blahblah'"
        Set oRS = New ADODB.Recordset
        oRS.Open sSql, oCon, adOpenStatic, adLockReadOnly
    
        Set Me.DataSource = oRS
    End Sub
    If you create procedures in Oracle, then you might do that instead of writing dynamic SQL in your VB app.
    Chris

    Master Of My Domain
    Got A Question? Look Here First

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