I have the following sql statement as a record source for a subform. I know there should be records being displayed however there are no records being displayed when I open the form.
I remove the criteria linked to the LoggedInAs and it seems to pull through records fine. Any ideas?
I remove the criteria linked to the LoggedInAs and it seems to pull through records fine. Any ideas?
Code:
SELECT dbo_Leads.*, dbo_Leads.LeadID, dbo_Leads.Title, dbo_Leads.Firstname, dbo_Leads.Surname, dbo_Leads.OutcomeID, dbo_Leads.NextTaskTime, dbo_Leads.OverallRankingScore, dbo_Leads.StatusScore, dbo_Leads.TelephoneScore, dbo_Leads.LoanSizeScore, dbo_Leads.DateAddedScore, dbo_Leads.LoanTypeScore, dbo_Leads.EquityScore, dbo_Leads.SourceScore, dbo_Leads.OutcomeLastModified, dbo_Leads.Adviser, dbo_Leads.TempAdviserLock, dbo_Leads.NextTaskTimeLock, dbo_Leads.LeadSource, dbo_Leads.DateAdded
FROM dbo_Leads
WHERE (((dbo_Leads.OutcomeID)="Pending") AND ((dbo_Leads.Adviser) Is Null) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free") AND ((dbo_Leads.LeadSource) Is Null Or (dbo_Leads.LeadSource) In (SELECT dbo_LeadSources.LeadSource
FROM dbo_NextTaskCriteriaSources INNER JOIN dbo_LeadSources ON int(dbo_NextTaskCriteriaSources.Source) = dbo_LeadSources.LeadSourceID
WHERE (((dbo_NextTaskCriteriaSources.EmployeeID)=[Forms]![frmNextTask]![LoggedInAs]))
GROUP BY dbo_LeadSources.LeadSource;))) OR (((dbo_Leads.OutcomeID)="No Answer") AND ((dbo_Leads.Adviser) Is Null) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free") AND ((dbo_Leads.LeadSource) Is Null Or (dbo_Leads.LeadSource) In (SELECT dbo_LeadSources.LeadSource
FROM dbo_NextTaskCriteriaSources INNER JOIN dbo_LeadSources ON int(dbo_NextTaskCriteriaSources.Source) = dbo_LeadSources.LeadSourceID
WHERE (((dbo_NextTaskCriteriaSources.EmployeeID)=[Forms]![frmNextTask]![LoggedInAs]))
GROUP BY dbo_LeadSources.LeadSource;))) OR (((dbo_Leads.OutcomeID)="Engaged") AND ((dbo_Leads.Adviser) Is Null) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free") AND ((dbo_Leads.LeadSource) Is Null Or (dbo_Leads.LeadSource) In (SELECT dbo_LeadSources.LeadSource
FROM dbo_NextTaskCriteriaSources INNER JOIN dbo_LeadSources ON int(dbo_NextTaskCriteriaSources.Source) = dbo_LeadSources.LeadSourceID
WHERE (((dbo_NextTaskCriteriaSources.EmployeeID)=[Forms]![frmNextTask]![LoggedInAs]))
GROUP BY dbo_LeadSources.LeadSource;))) OR (((dbo_Leads.OutcomeID)="Future Business") AND ((dbo_Leads.Adviser) Is Null) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free") AND ((dbo_Leads.LeadSource) Is Null Or (dbo_Leads.LeadSource) In (SELECT dbo_LeadSources.LeadSource
FROM dbo_NextTaskCriteriaSources INNER JOIN dbo_LeadSources ON int(dbo_NextTaskCriteriaSources.Source) = dbo_LeadSources.LeadSourceID
WHERE (((dbo_NextTaskCriteriaSources.EmployeeID)=[Forms]![frmNextTask]![LoggedInAs]))
GROUP BY dbo_LeadSources.LeadSource;))) OR (((dbo_Leads.OutcomeID)="Waiting on Base Rate Moving") AND ((dbo_Leads.Adviser) Is Null) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free") AND ((dbo_Leads.LeadSource) Is Null Or (dbo_Leads.LeadSource) In (SELECT dbo_LeadSources.LeadSource
FROM dbo_NextTaskCriteriaSources INNER JOIN dbo_LeadSources ON int(dbo_NextTaskCriteriaSources.Source) = dbo_LeadSources.LeadSourceID
WHERE (((dbo_NextTaskCriteriaSources.EmployeeID)=[Forms]![frmNextTask]![LoggedInAs]))
GROUP BY dbo_LeadSources.LeadSource;))) OR (((dbo_Leads.OutcomeID)="Scheduled Call Unsuccessful") AND ((dbo_Leads.Adviser) Is Null) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free") AND ((dbo_Leads.LeadSource) Is Null Or (dbo_Leads.LeadSource) In (SELECT dbo_LeadSources.LeadSource
FROM dbo_NextTaskCriteriaSources INNER JOIN dbo_LeadSources ON int(dbo_NextTaskCriteriaSources.Source) = dbo_LeadSources.LeadSourceID
WHERE (((dbo_NextTaskCriteriaSources.EmployeeID)=[Forms]![frmNextTask]![LoggedInAs]))
GROUP BY dbo_LeadSources.LeadSource;))) OR (((dbo_Leads.OutcomeID)="Pending") AND ((dbo_Leads.Adviser)=[Forms]![frmNextTask]![LoggedInAs]) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free") AND ((dbo_Leads.LeadSource) Is Null Or (dbo_Leads.LeadSource) In (SELECT dbo_LeadSources.LeadSource
FROM dbo_NextTaskCriteriaSources INNER JOIN dbo_LeadSources ON int(dbo_NextTaskCriteriaSources.Source) = dbo_LeadSources.LeadSourceID
WHERE (((dbo_NextTaskCriteriaSources.EmployeeID)=[Forms]![frmNextTask]![LoggedInAs]))
GROUP BY dbo_LeadSources.LeadSource;))) OR (((dbo_Leads.OutcomeID)="No Answer") AND ((dbo_Leads.Adviser)=[Forms]![frmNextTask]![LoggedInAs]) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free") AND ((dbo_Leads.LeadSource) Is Null Or (dbo_Leads.LeadSource) In (SELECT dbo_LeadSources.LeadSource
FROM dbo_NextTaskCriteriaSources INNER JOIN dbo_LeadSources ON int(dbo_NextTaskCriteriaSources.Source) = dbo_LeadSources.LeadSourceID
WHERE (((dbo_NextTaskCriteriaSources.EmployeeID)=[Forms]![frmNextTask]![LoggedInAs]))
GROUP BY dbo_LeadSources.LeadSource;))) OR (((dbo_Leads.OutcomeID)="Engaged") AND ((dbo_Leads.Adviser)=[Forms]![frmNextTask]![LoggedInAs]) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free") AND ((dbo_Leads.LeadSource) Is Null Or (dbo_Leads.LeadSource) In (SELECT dbo_LeadSources.LeadSource
FROM dbo_NextTaskCriteriaSources INNER JOIN dbo_LeadSources ON int(dbo_NextTaskCriteriaSources.Source) = dbo_LeadSources.LeadSourceID
WHERE (((dbo_NextTaskCriteriaSources.EmployeeID)=[Forms]![frmNextTask]![LoggedInAs]))
GROUP BY dbo_LeadSources.LeadSource;))) OR (((dbo_Leads.OutcomeID)="Future Business") AND ((dbo_Leads.Adviser)=[Forms]![frmNextTask]![LoggedInAs]) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free") AND ((dbo_Leads.LeadSource) Is Null Or (dbo_Leads.LeadSource) In (SELECT dbo_LeadSources.LeadSource
FROM dbo_NextTaskCriteriaSources INNER JOIN dbo_LeadSources ON int(dbo_NextTaskCriteriaSources.Source) = dbo_LeadSources.LeadSourceID
WHERE (((dbo_NextTaskCriteriaSources.EmployeeID)=[Forms]![frmNextTask]![LoggedInAs]))
GROUP BY dbo_LeadSources.LeadSource;))) OR (((dbo_Leads.OutcomeID)="Waiting on Base Rate Moving") AND ((dbo_Leads.Adviser)=[Forms]![frmNextTask]![LoggedInAs]) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free") AND ((dbo_Leads.LeadSource) Is Null Or (dbo_Leads.LeadSource) In (SELECT dbo_LeadSources.LeadSource
FROM dbo_NextTaskCriteriaSources INNER JOIN dbo_LeadSources ON int(dbo_NextTaskCriteriaSources.Source) = dbo_LeadSources.LeadSourceID
WHERE (((dbo_NextTaskCriteriaSources.EmployeeID)=[Forms]![frmNextTask]![LoggedInAs]))
GROUP BY dbo_LeadSources.LeadSource;))) OR (((dbo_Leads.OutcomeID)="Scheduled Call Unsuccessful") AND ((dbo_Leads.Adviser)=[Forms]![frmNextTask]![LoggedInAs]) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free") AND ((dbo_Leads.LeadSource) Is Null Or (dbo_Leads.LeadSource) In (SELECT dbo_LeadSources.LeadSource
FROM dbo_NextTaskCriteriaSources INNER JOIN dbo_LeadSources ON int(dbo_NextTaskCriteriaSources.Source) = dbo_LeadSources.LeadSourceID
WHERE (((dbo_NextTaskCriteriaSources.EmployeeID)=[Forms]![frmNextTask]![LoggedInAs]))
GROUP BY dbo_LeadSources.LeadSource;))) OR (((dbo_Leads.OutcomeID)="Pending") AND ((dbo_Leads.Adviser)=[Forms]![frmNextTask]![LoggedInAs]) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free")) OR (((dbo_Leads.OutcomeID)="No Answer") AND ((dbo_Leads.Adviser)=[Forms]![frmNextTask]![LoggedInAs]) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free")) OR (((dbo_Leads.OutcomeID)="Engaged") AND ((dbo_Leads.Adviser)=[Forms]![frmNextTask]![LoggedInAs]) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free")) OR (((dbo_Leads.OutcomeID)="Future Business") AND ((dbo_Leads.Adviser)=[Forms]![frmNextTask]![LoggedInAs]) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free")) OR (((dbo_Leads.OutcomeID)="Waiting on Base Rate Moving") AND ((dbo_Leads.Adviser)=[Forms]![frmNextTask]![LoggedInAs]) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free")) OR (((dbo_Leads.OutcomeID)="Scheduled Call Unsuccessful") AND ((dbo_Leads.Adviser)=[Forms]![frmNextTask]![LoggedInAs]) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free")) OR (((dbo_Leads.OutcomeID)="Pending") AND ((dbo_Leads.Adviser) Is Null) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free")) OR (((dbo_Leads.OutcomeID)="No Answer") AND ((dbo_Leads.Adviser) Is Null) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free")) OR (((dbo_Leads.OutcomeID)="Engaged") AND ((dbo_Leads.Adviser) Is Null) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free")) OR (((dbo_Leads.OutcomeID)="Future Business") AND ((dbo_Leads.Adviser) Is Null) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free")) OR (((dbo_Leads.OutcomeID)="Waiting on Base Rate Moving") AND ((dbo_Leads.Adviser) Is Null) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free")) OR (((dbo_Leads.OutcomeID)="Scheduled Call Unsuccessful") AND ((dbo_Leads.Adviser) Is Null) AND ((dbo_Leads.TempAdviserLock)="Free") AND ((dbo_Leads.NextTaskTimeLock)="Free"))
ORDER BY dbo_Leads.DateAdded DESC , dbo_Leads.LTVPercentage;