I have code that runs thru a record set and for each record, sets the dept as a query criteria and then runs a union query based on the current dept. I am wondering if there's a way to have one of the queries run thru with multiple criteria (ie: where it says dept = TP, I would like to change the criteria to = TP or Bos.) I know this updated code that follows is not 100%, but my main concern is the strDept = Bos or TP line. How (if this is possible) do I arrange the quotes correctly?
Here's what I have - again, I know the code isn't all done, I just can't seem to figure out the "double criteria" definition...
Do While Not rstDepts.EOF
strDept = rstDepts!Department
If strDept = "Bos" Then
rstDepts.MoveNext
Else
If strDept = "T-P" Then
strDept = "'Bos' Or 'T-P'"
Set rstTemp = CurrentDb.OpenRecordset("qry_union1"
If rstTemp.RecordCount > 0 Then
strFileName = strpath & strDept & StrCurrDte & ".xls"
DoCmd.OutputTo acOutputQuery, "qry_union1", acFormatXLS, strFileName
End If
rstDepts.MoveNext
Else
Set rstTemp = CurrentDb.OpenRecordset("qry_union1"
If rstTemp.RecordCount > 0 Then
strFileName = strpath & strDept & StrCurrDte & ".xls"
DoCmd.OutputTo acOutputQuery, "qry_union1", acFormatXLS, strFileName
End If
rstDepts.MoveNext
End If
End If
Loop
Here's what I have - again, I know the code isn't all done, I just can't seem to figure out the "double criteria" definition...
Do While Not rstDepts.EOF
strDept = rstDepts!Department
If strDept = "Bos" Then
rstDepts.MoveNext
Else
If strDept = "T-P" Then
strDept = "'Bos' Or 'T-P'"
Set rstTemp = CurrentDb.OpenRecordset("qry_union1"
If rstTemp.RecordCount > 0 Then
strFileName = strpath & strDept & StrCurrDte & ".xls"
DoCmd.OutputTo acOutputQuery, "qry_union1", acFormatXLS, strFileName
End If
rstDepts.MoveNext
Else
Set rstTemp = CurrentDb.OpenRecordset("qry_union1"
If rstTemp.RecordCount > 0 Then
strFileName = strpath & strDept & StrCurrDte & ".xls"
DoCmd.OutputTo acOutputQuery, "qry_union1", acFormatXLS, strFileName
End If
rstDepts.MoveNext
End If
End If
Loop