Results 1 to 4 of 4

Thread: 2 tables 1 report issue

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    12

    2 tables 1 report issue

    I have created a report in CR XI that uses 2 tables from an access database. 2 fields are from one table and the 3rd field is from the other. When I preview the report in CR, it gives me the correct results.

    User1

    Site1
    Site2
    Site3

    When I call the report in VB.NET 2003 it duplicates the results.

    User1

    Site1
    Site1
    Site1
    Site2
    Site2
    Site2
    Site3
    Site3
    Site3

    Here is the code that I am calling the report in VB.NET.

    strsql = "SELECT tblUser.UserName, tblUser.Administrator, Security_Access.Site_ID FROM tblUser INNER JOIN Security_Access ON tblUser.UserName = Security_Access.UserName"
    reportname = apppath & "\rpt_users.rpt"


    Dim con As New OleDb.OleDbConnection

    'Create a connection to specified database
    con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & inpdatabase & ";")
    'Open connection
    con.Open()
    da = New OleDb.OleDbDataAdapter(strsql, con)
    da.Fill(ds, "User")

    con.Close()

    rd = New ReportDocument
    rd.Load(reportname)
    rd.SetDataSource(ds)

    crvMain.ReportSource = rd

    Thanks
    mmars

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: 2 tables 1 report issue

    strsql = "SELECT tblUser.UserName, tblUser.Administrator, Security_Access.Site_ID FROM tblUser INNER JOIN Security_Access ON tblUser.UserName = Security_Access.UserName"
    VB Code:
    1. strsql = "SELECT Distinct tblUser.UserName, tblUser.Administrator, Security_Access.Site_ID FROM tblUser INNER JOIN Security_Access ON tblUser.UserName = Security_Access.UserName"
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    12

    Re: 2 tables 1 report issue

    Thanks for your reply but DISTINCT and DISTINCTROW did not work. I'm still getting the duplicate records.

    mmars

  4. #4
    Junior Member
    Join Date
    Feb 2006
    Posts
    27

    Re: 2 tables 1 report issue

    I don't know what and how is the information stored in the two tables. Did you try to copy the query into Query Analyzer?... Maybe you must modify the JOIN... (Perhaps a LEFT or RIGHT?)

    Regards,
    Tribo
    Last edited by Tribo; Feb 20th, 2006 at 01:20 AM.

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