Hi, I wanted to save the following Query, but only wanted to save Queries with Data in them since some of these Queries will have no Data in them. I wanted to save the Queries with DATA in them. Could you let me know what Argument should I be using in my DCount Statement??
SQL = "SELECT A.CID, A.month, A.contractyear, "
SQL = SQL & "A.BranchName, B.Report"
SQL = SQL & " FROM tbl1 AS B INNER JOIN tbl2 AS A"
SQL = SQL & " ON B.BranchName = A.BranchName"
SQL = SQL & " WHERE B.Report='" & ReportType & "'"
SQL = SQL & " and A.BranchName=" & MSA_SA(Iteration)
SQL = SQL & " Order by A.CID"
Set db = CurrentDb
If DCount("*", SQL) > 0 Then
db.CreateQueryDef MSA_SA & " QUERY", SQL
End If
On Error Resume Next
SQL = "SELECT A.CID, A.month, A.contractyear, "
SQL = SQL & "A.BranchName, B.Report"
SQL = SQL & " FROM tbl1 AS B INNER JOIN tbl2 AS A"
SQL = SQL & " ON B.BranchName = A.BranchName"
SQL = SQL & " WHERE B.Report='" & ReportType & "'"
SQL = SQL & " and A.BranchName=" & MSA_SA(Iteration)
SQL = SQL & " Order by A.CID"
Set db = CurrentDb
If DCount("*", SQL) > 0 Then
db.CreateQueryDef MSA_SA & " QUERY", SQL
End If
On Error Resume Next