I need to add a sub query or nested query in a module. Can someone take a look and let me know if it's even possible.
Here is what I have so far. When I try to run it it doesn t do anything.
HELP
Dim strsqr As String
strsqu = " And (((tblProgram.ProgramID) IN (Select tblProgram.ProgramID From tblClient INNER JOIN (tblClientUsage LEFT JOIN tblProgram ON tblClientUsage.ProgramID = tblProgram.ProgramID))))"
With qry
.SQL = "SELECT tblProgram.ProgramID, tblClient.ClientID,tblClient.ClientFirstname, tblClient.ClientIDHistory, tblClient.ClientLastname, tblClient.ClientSSnum, tblClient.ClientAge, tblClient.ClientDOB, tblClient.Diabled," _
& " tblClient.IsChild, tblClient.ResidesInJacksonCoun, tblClient.ClientReq4Services, tblClient.ReferredBy, tblClient.AnnualIncome, tblClient.IntakeCreated, tblClient.ClientClosed," _
& " tblClient.ClientIntakeNotes, tblClient.DeclinedServices, tblClient.WaitingList, LK_MaritalStatus.MaritalStatus, LK_Race.Race, LK_IntakeIssues.IntakeIssues, LK_ClientStatus.ClientStatus," _
& " [StaffFname] & ' ' & [StaffLname] AS Intake_Worker, LK_Ethnicity.Ethnicity, tblClient.Gender, tblClient.ClientIDHistory, tblClient.ClientOpened, LK_Service.Service, tblClient.FemaleHead, LK_Annual_Income.Annual_Income_Text, #" & Me!txtStartDate & "# as StartDate, #" & Me!txtEndDate & "# as EndDate" _
& " FROM LK_Ethnicity RIGHT JOIN (((((((LK_MaritalStatus RIGHT JOIN tblClient ON LK_MaritalStatus.MaritalStatusID = tblClient.MaritalStatusID) LEFT JOIN LK_Race ON tblClient.ClientRaceID = LK_Race.RaceID) LEFT JOIN" _
& " LK_IntakeIssues ON tblClient.IntakeIssueID = LK_IntakeIssues.IntakeIssuesID) LEFT JOIN LK_ClientStatus ON tblClient.ClientStatusID = LK_ClientStatus.ClientStatusID) LEFT JOIN tblStaff ON tblClient.IntakeWorker = tblStaff.StaffID)" _
& " LEFT JOIN LK_Service ON tblClient.Service_ID = LK_Service.ServiceID)LEFT JOIN LK_Annual_Income ON tblClient.Annual_Income_Frame = LK_Annual_Income.Annual_Income_ID) ON LK_Ethnicity.Ethnicity_ID = tblClient.Ethnicity" _
& strWhere _
& strWhere1 _
& strsqu
End With
Here is what I have so far. When I try to run it it doesn t do anything.
HELP
Dim strsqr As String
strsqu = " And (((tblProgram.ProgramID) IN (Select tblProgram.ProgramID From tblClient INNER JOIN (tblClientUsage LEFT JOIN tblProgram ON tblClientUsage.ProgramID = tblProgram.ProgramID))))"
With qry
.SQL = "SELECT tblProgram.ProgramID, tblClient.ClientID,tblClient.ClientFirstname, tblClient.ClientIDHistory, tblClient.ClientLastname, tblClient.ClientSSnum, tblClient.ClientAge, tblClient.ClientDOB, tblClient.Diabled," _
& " tblClient.IsChild, tblClient.ResidesInJacksonCoun, tblClient.ClientReq4Services, tblClient.ReferredBy, tblClient.AnnualIncome, tblClient.IntakeCreated, tblClient.ClientClosed," _
& " tblClient.ClientIntakeNotes, tblClient.DeclinedServices, tblClient.WaitingList, LK_MaritalStatus.MaritalStatus, LK_Race.Race, LK_IntakeIssues.IntakeIssues, LK_ClientStatus.ClientStatus," _
& " [StaffFname] & ' ' & [StaffLname] AS Intake_Worker, LK_Ethnicity.Ethnicity, tblClient.Gender, tblClient.ClientIDHistory, tblClient.ClientOpened, LK_Service.Service, tblClient.FemaleHead, LK_Annual_Income.Annual_Income_Text, #" & Me!txtStartDate & "# as StartDate, #" & Me!txtEndDate & "# as EndDate" _
& " FROM LK_Ethnicity RIGHT JOIN (((((((LK_MaritalStatus RIGHT JOIN tblClient ON LK_MaritalStatus.MaritalStatusID = tblClient.MaritalStatusID) LEFT JOIN LK_Race ON tblClient.ClientRaceID = LK_Race.RaceID) LEFT JOIN" _
& " LK_IntakeIssues ON tblClient.IntakeIssueID = LK_IntakeIssues.IntakeIssuesID) LEFT JOIN LK_ClientStatus ON tblClient.ClientStatusID = LK_ClientStatus.ClientStatusID) LEFT JOIN tblStaff ON tblClient.IntakeWorker = tblStaff.StaffID)" _
& " LEFT JOIN LK_Service ON tblClient.Service_ID = LK_Service.ServiceID)LEFT JOIN LK_Annual_Income ON tblClient.Annual_Income_Frame = LK_Annual_Income.Annual_Income_ID) ON LK_Ethnicity.Ethnicity_ID = tblClient.Ethnicity" _
& strWhere _
& strWhere1 _
& strsqu
End With