Hello all. Just wondering. I've included a SQL statement that has a compound WHERE. Now I want to add an additional required condition. Can I nest it by placing parens before and after the current WHERE and add my added condition with an AND before the parens? Like this:
"WHERE [COLOR=red yellow][AllSections].[A]="" AND [/color]([AllSections].[Instr1] = '" & Me!cboInstrName & "' AND [AllSections].[DivNum]= '" & Me!txtDivNum & "' OR [AllSections].[Instr2] = '" & Me!cboInstrName & "' AND [AllSections].[DivNum]= '" & Me!txtDivNum & "' OR [AllSections].[Instr3] = '" & Me!cboInstrName & "' AND [AllSections].[DivNum]= '" & Me!txtDivNum & "' OR [AllSections].[Instr4] = '" & Me!cboInstrName & "' AND [AllSections].[DivNum]= '" & Me!txtDivNum & "') " & _
Amadea
"WHERE [COLOR=red yellow][AllSections].[A]="" AND [/color]([AllSections].[Instr1] = '" & Me!cboInstrName & "' AND [AllSections].[DivNum]= '" & Me!txtDivNum & "' OR [AllSections].[Instr2] = '" & Me!cboInstrName & "' AND [AllSections].[DivNum]= '" & Me!txtDivNum & "' OR [AllSections].[Instr3] = '" & Me!cboInstrName & "' AND [AllSections].[DivNum]= '" & Me!txtDivNum & "' OR [AllSections].[Instr4] = '" & Me!cboInstrName & "' AND [AllSections].[DivNum]= '" & Me!txtDivNum & "') " & _
Code:
strSQL2 = "SELECT [AllSections].[A], [AllSections].[Master], [AllSections].[Sect], [AllSections].[CourseID], [AllSections].[BeginTime1] AS BeginTime, [AllSections].[EndTime1] AS EndTime, [AllSections].[Days1] AS Days, [AllSections].[Room1] AS Room, [AllSections].[BeginDate], [AllSections].[Wks], [AllSections].[MaxSeats] " & _
"FROM AllSections " & _
"WHERE [AllSections].[Instr1] = '" & Me!cboInstrName & "' AND [AllSections].[DivNum]= '" & Me!txtDivNum & "' OR [AllSections].[Instr2] = '" & Me!cboInstrName & "' AND [AllSections].[DivNum]= '" & Me!txtDivNum & "' OR [AllSections].[Instr3] = '" & Me!cboInstrName & "' AND [AllSections].[DivNum]= '" & Me!txtDivNum & "' OR [AllSections].[Instr4] = '" & Me!cboInstrName & "' AND [AllSections].[DivNum]= '" & Me!txtDivNum & "' " & _
"ORDER BY [AllSections].[Master], [AllSections].[CourseID];"
Amadea