I have a SLQ Statement using a prompt to get the value of two codes from the user. This should be an easy thing but the result is not what I expect. Can anyone spot the problem? When I type in 8000 for the start ID and 8999 for the end ID, I want only ActID between 8000 and 8999 but I get codes between 8000 and 8999 as well as codes between 80000 and 89999, and codes between 800000 and 899999! Very odd. The ActID field is a text field and all ID's have leading spaces " 8000" is the Activity ID for 8000 and " 80000" is the ID for 80000. This query should only evaluate the right 5 characters of the ActID.
Any help would be appreciated!
Any help would be appreciated!
Code:
PARAMETERS [Start Activity ID:] Value, [End Activity ID:] Value; SELECT qryMnth.Job, qryMnth.Phase, tblCftSum.Srt1 AS Craft, qryMnth.ActID, qryMnth.Act_Title, tblProjInfo.Period, [qryMnth]![PeriodFinish] AS RptDte, Sum(qryMnth.BHrs) AS BHrs, Sum(qryMnth.AHrs_td) AS [AHrs ToDate], Sum([qryMnth].[AHrs_td]-[qryMnth].[AHrs_lm]) AS [AHrs Period], Sum(qryMnth.EHrs_td) AS [EHrs ToDate], Sum([qryMnth].[EHrs_td]-[qryMnth].[EHrs_lm]) AS [EHrs Period], Sum(qryProj.PHrs_sl) AS SLHrs, Sum(qryProj.PHrs_wm) AS MPHrs, Sum(qryMnth.BTot) AS BCst, Sum(qryMnth.ATot_td) AS [ACst ToDate], Sum([qryMnth].[ATot_td]-[qryMnth].[ATot_lm]) AS [ACst Period], Sum(qryMnth.ETot_td) AS [ECst ToDate], Sum([qryMnth].[ETot_td]-[qryMnth].[ETot_lm]) AS [ECst Period], Sum(qryProj.PTot_sl) AS SLCst, Sum(qryProj.PTot_wm) AS PMCst, 1 AS PFT, IIf([AHrs ToDate]=0 Or [EHrs ToDate]=0,0,[AHrs ToDate]/[EHrs ToDate]) AS PFTD, IIf([EHrs Period]=0,0,[AHrs Period]/[EHrs Period]) AS PFTP, IIf([AHrs ToDate]=0 Or [EHrs ToDate]=0,0,([MPHrs]-[AHrs ToDate])/([BHrs]-[EHrs ToDate])) AS PFTG, IIf([AHrs ToDate]=0 Or [EHrs ToDate]=0,0,[MPHrs]/[BHrs]) AS PFAC FROM tblUser_Sort RIGHT JOIN (tblCftSum RIGHT JOIN (((qryMnth LEFT JOIN tblActMap ON qryMnth.S_Key = tblActMap.S_Key) LEFT JOIN tblProjInfo ON qryMnth.PeriodFinish = tblProjInfo.Period_Dte) LEFT JOIN qryProj ON qryMnth.P_Key = qryProj.P_Key) ON tblCftSum.Srt1 = tblActMap.Srt1) ON tblUser_Sort.Srt4 = tblActMap.Srt4 WHERE (((Val(Right(Trim([qryMnth]![ActID]),5))) Between [Start Activity ID:] And [End Activity ID:])) GROUP BY qryMnth.Job, qryMnth.Phase, tblCftSum.Srt1, qryMnth.ActID, qryMnth.Act_Title, tblProjInfo.Period, [qryMnth]![PeriodFinish] HAVING (((tblCftSum.Srt1)<>"07") AND ((tblProjInfo.Period)>=0)) ORDER BY qryMnth.Job, qryMnth.Phase, tblCftSum.Srt1, qryMnth.ActID;
Comment