Do not use on any
shared computer
August 29, 2008 06:02pm pdt
 
[x]
Attachment Details

SQL Help

Hi experts!

I seem to be having problems with a SQL statement that I use to create a report in MS Access 2000. This speicific line in my sql statement: "sql = sql & "Or D.PayrollException = True " (refer to the complete SQL below) causes my Access to just say 'running query' in the bottom left screen of ACCESS (sort of like a status bar) but it doesn't seem to complete. It eats up my resources but it won't do anything and I have to manually close the application via the task manager.  If I remove that line, everything works fine (the report shows up almost immedaitely). Any suggestions would be really appreciated. Thanks!

    sql = "SELECT DISTINCTROW B.PeriodEnding, "
    sql = sql & "A.EmployeeNumber, "
    sql = sql & "A.LastName & ', ' & A.FirstName AS EmployeeName, "
    sql = sql & "E.Facility, "
    sql = sql & "A.WorkDept, "
    sql = sql & "B.ChargeNumber, "
    sql = sql & "D.ActivityDesc, "
    sql = sql & "B.Description, "
    sql = sql & "B.IsDemand, "
    sql = sql & "B.IsOvertime, "
    sql = sql & "D.PayrollException, "
    sql = sql & "B.CapitalProject, "
    sql = sql & "SUM(B.RegularHours) AS RegularHours, "
    sql = sql & "SUM(B.PayrollHours) AS PayrollHours, "
    sql = sql & "CCur(SUM(B.RegularHours) * C.RegularRate + ((SUM(B.PayrollHours) - SUM(B.RegularHours)) * C.OvertimeRate)) AS PayAmount "
    sql = sql & "FROM tblEmployee AS A, tblJobHistory AS B, tlkpLevel AS C, tlkpActivity D, tlkpFacility E "
    sql = sql & "WHERE A.EmployeeNumber = B.EmployeeNumber "
    sql = sql & "AND A.CurrentLevel = C.Level "
    sql = sql & "AND B.ActivityID = D.ActivityID "
    sql = sql & "AND A.FacilityID = E.FacilityID "
    sql = sql & "AND PeriodEnding BETWEEN #" & g_from_date & "# AND #" & g_to_date & "# "
    sql = sql & "AND B.IsOvertime = True "
    sql = sql & "Or D.PayrollException = True "
    sql = sql & "GROUP BY B.PeriodEnding, A.EmployeeNumber, A.LastName, A.FirstName, E.Facility, "
    sql = sql & "A.WorkDept, B.ChargeNumber, B.Description, C.RegularRate, C.OvertimeRate, D.ActivityDesc, "
    sql = sql & "B.IsDemand, B.IsOvertime, D.PayrollException, B.CapitalProject "
    sql = sql & "ORDER BY A.WorkDept, E.Facility, A.LastName;"
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Microsoft
Question Asked By: rusco
Solution Provided By: vaidisok
Participating Experts: 1
Solution Grade: A
Views: 0
Translate:
Loading Advertisement...
 
[+][-]Accepted Solution by vaidisok
Accepted Solution by vaidisok:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by rusco
Author Comment by rusco:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34