Các bác PRO xem giúp em đoạn code này, sao em chạy không được:
Mã:
Sub DSKH()
Dim DB As Database
Dim QR1 As QueryDef
Dim tbl2 As Recordset
Dim sql As String
Set DB = CurrentDb
Set QR1 = DB.CreateQueryDef
QR1.sql = " select count(sohd) as slhd, maso, sum(sotien) as sotien from table1 group by maso;"
DB.Execute "select qr1.maso, tblKH.ten, qr1.sotien, qry.slhd into tbl2 from QRA left join tblKH on qr1.maso=tblKH.maso;"
Set DB = Nothing
End Sub