PellaWhereClause = "AND IIF(tPlans.PlanID = 7287,'ALLTRIM(web_PlanDocs.cName) == IIF(web_PMEmp.ExecTitle = 'SA2','Plan Document - Executive SPP','Plan Document - Executive SPP')" + ",.T.)" *-- Retrieve plan forms for all of the accounts the user is participating in SELECT DISTINCT ; PADR(IIF(ALLTRIM(web_plandocs.cname) == 'PIN Form', "Plan Participant Web Access Form", web_plandocs.cname), 60) as cname, ; PADR(web_plandocs.mdesc, 250) as mdesc, ; web_plandocs.lscripted, ; web_plandocs.cfilename, ; web_plandocs.ntempltid, ; web_pmplan.planname, ; web_plandocs.planid ; FROM web_plandocs JOIN tplans ON tplans.planid = web_plandocs.planid ; JOIN web_pmplan ON web_pmplan.planid = web_plandocs.planid ; WHERE web_pmplan.nplancode = m.plancode ; AND web_plandocs.idnum = m.idnum ; AND web_plandocs.dtype = 1 &filter_PIN &PellaWhereClause ; ORDER BY web_pmplan.planname, web_pmplan.planid, web_plandocs.cname ; INTO CURSOR tdoc