How to Build formula/Insert Query in Crystal report in Vb.net 2005 RRS feed

  • Question

  • Dear Sir/Madam,
                           I Have an Employee table in the access database. The various fields in that table are.

    1. EmpId(Number)
    2. EmpName(text)
    3. Desiganation(text)
    4. ReportingToId(Number)
    5. EmailId(text)
    6. ContactNo(Number)
    Now at the ReportingToId i saved the EmpId of the person to whom he is reportoing. but now in the crystal Report  i want the name of the employee (EmpName) whose EmpId=ReportingToId in crystal report.

    The Query Related to tihs is

    SELECT Employee.name
    FROM Employee
    WHERE (((Employee.EmpID)=(Select reportingTo from employee where empid=[Id])));
    Saturday, November 1, 2008 7:25 AM


  • There are 2 approaches:
    1. Join SQL in your SQL Statement.

    Select Employee.*, ReportingTo.EmpName as ReportingToName From Employee Inner Join  Employee As ReportingTo On Employee.ReportingToId = ReportingTo.EmpId

    2. Push the Join in to your report file.

    That means, you design a report with 2 tables: Employee, ReportingTo (Alias of second Employee table),
    then you inner join them (Employee.ReportingToId -> ReportingTo.EmpId) in Database Experts -> Links.

    Sincerely yours

    Sean Zhu

    Monday, November 3, 2008 10:29 PM