Hello,

I'm getting Data type mismatch for the below query, seeking for your advises please.


SqlQuery = "SELECT COUNT(*) AS Report_ID,q1.Report_Name,q1.Report_Owner FROM (SELECT Report_ID,Report_Name,Report_Owner FROM tbl_Monday UNION ALL SELECT Report_ID,Report_Name,Report_Owner FROM tbl_Tuesday UNION ALL SELECT Report_ID,Report_Name,Report_Owner FROM tbl_Wednesday) q1 INNER JOIN(SELECT Report_ID,Report_Name,Report_Owner FROM tbl_Monday UNION ALL SELECT Report_ID,Report_Name,Report_Owner FROM tbl_Tuesday UNION ALL SELECT Report_ID,Report_Name,Report_Owner FROM tbl_Wednesday) q2 on CLng(Val(q1.Report_ID)) + q1.Report_Name + q1.Report_Owner >= CLng(Val(q2.Report_ID)) + q2.Report_Name + q2.Report_Owner GROUP BY q1.Report_ID,q1.Report_Name,q1.Report_Owner"

rs.Open SqlQuery, conn

        With rs
        
            Do While Not .EOF
                Set litem = frm_ALLREPORTS.lv_ALLREPORTS.ListItems.Add(, , .Fields("Report_ID").Value)
                litem.SubItems(1) = .Fields("Report_Name").Value
                                litem.SubItems(2) = .Fields("Report_Owner").Value


.MoveNext
            Loop
            
        End With

conn.Close
Thanks in advance Gurus!