I can't seem to figure out how to write this IF statement.
Any help is appreciated: See my commented out lines in the following code.
Any help is appreciated: See my commented out lines in the following code.
Code:
....
'open your query as RecordSource
Set qdf = CurrentDb.QueryDefs("qry_55")
With qdf
qdfOLD = .SQL
.SQL = Replace(.SQL, "c.cnty_cd ='01'", "c.cnty_cd =" & "'" & x & "'")
DoCmd.OpenQuery "qry_55"
DoCmd.Close
[COLOR=red] 'If no results then go to Set qdf = CurrentDb.QueryDefs("qry_175")[/COLOR]
[COLOR=red] 'Else go to next line and output rpt.[/COLOR]
DoCmd.OutputTo acOutputReport, "Rpt_55", acFormatPDF, _
"C:\Test\" & x & "\SS" & x & "Rpt55.pdf", False
.SQL = qdfOLD ' Reset SQL to old setting
End With '55
Set qdf = CurrentDb.QueryDefs("qry_175")
With qdf
qdfOLD = .SQL
.SQL = Replace(.SQL, "(cp.cnty_cd)= '01'", "(cp.cnty_cd)= " & "'" & x & "'")
DoCmd.OpenQuery "qry_175"
DoCmd.Close
'export report 175
DoCmd.OutputTo acOutputReport, "Rpt_175", acFormatPDF, _
"C:\Test\" & x & "\SS" & x & "Rpt175.pdf", False
.SQL = qdfOLD ' Reset SQL to old setting
End With '175