Affichage des articles dont le libellé est If no results then move to next qryDef..... Afficher tous les articles
Affichage des articles dont le libellé est If no results then move to next qryDef..... Afficher tous les articles

If no results then move to next qryDef....

mercredi 22 avril 2015

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.

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
 
              'If no results then go to Set qdf = CurrentDb.QueryDefs("qry_175")
              'Else go to next line and output rpt.
 
                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

If no results then move to next qryDef....

Labels