انسخ و الصف الكود في حدث لأي ازرار
مرفق التعديل
On Error Resume Next
DoCmd.SetWarnings False
DoCmd.RunSQL "SELECT sheet.dept_code, sheet.dept_name, " _
& " Val(Nz(DCount('*','sheet',' dept_code= ' & [dept_code] & ' and c_moslem = 1'),0)) AS مسلم, " _
& " Val(Nz(DCount('*','sheet',' dept_code= ' & [dept_code] & ' and c_moslem = 2'),0)) AS مسيحي, " _
& " Val(Nz(DCount('*','sheet',' dept_code= ' & [dept_code] & ' and c_male = 1'),0)) AS ذكر, " _
& " Val(Nz(DCount('*','sheet',' dept_code= ' & [dept_code] & ' and c_male = 2'),0)) AS انثى, " _
& " Val(Nz(DCount('*','sheet',' dept_code= ' & [dept_code] & ' '),0)) AS جملة " _
& " INTO sheet1 FROM sheet GROUP BY sheet.dept_code, sheet.dept_name;"
DoCmd.SetWarnings True
MsgBox "تم جمع البيانات بنجاح" & vbNewLine & "New Table Name" & " : " & " sheet1 ", vbInformation + vbMsgBoxRight, "تأكيد"
sheet_hani.mdb