اذهب الي المحتوي
أوفيسنا

تجميع وفرز البيانات بالكود


الردود الموصى بها

  • 2 months later...

DoCmd.OpenReport "rpt", acViewLayout
 Dim varGroupLevel As Variant
  varGroupLevel = CreateGroupLevel("rpt", "classroom", True, True)
 Reports!rpt.Section(acGroupLevel1Header).Height = 0
Reports!rpt.Section(acGroupLevel1Footer).Height = 0
Reports!rpt.Section(acGroupLevel1Header).ForceNewPage = 1
لقد قمت باستخدام هذا الكود لعمل تجميع للبيانات في التقرير ولكن تحذث مشكلة بعد انشاء التقرير وعمل هذا التجميع يتغير عرض التقرير تقريبا الي الضعف يعتي انا محدد عرض صفحة التقرير 19 اجد عرض الصفحة بعد انشاء التجميع 38 وحاولت تحدير عرض التقرير بعد انشاء التجميع الي 19 ولكن لا يستجيب ويجعل العرض 38 فما حل هذه المشكلة شكرا

رابط هذا التعليق
شارك

السلام عليكم ورحمة الله وبركاته

أولا- لماذا تركت الحل السهل وهو تحديد المجموعة في عرض تصميم التقرير ولجأت للكود!

ثانيا- لو وضعت مرفقا يحوي التقرير الذي به المشكلة لنعاين المشكلة علي أرض الواقع :biggrin: وتسهيلا لطلب المزيد من التوضيح لكان أحسن!

ثالثا- أقترح عليك الحل السهل أن تجعل الـ Grouplevel  عند تصميم التقرير ثم تفرز بيانات التقرير من خلال الاستعلام كيفما تشاء وان كنت ولا بد بحاجة الي الكود - فأرجو أن ترجع الي النقطة ثانيا ☝️

 

رابط هذا التعليق
شارك

 

 

strReportName = "rpt"
strSQL = "SELECT * FROM basicdata ORDER BY student_name;"
If DCount("[Name]", "MSysObjects", "[Name] = 'rpt'") = 1 Then
DoCmd.DeleteObject acReport, "rpt"
End If
Set rptCustomers = CreateReport
With rptCustomers
.RecordSource = strSQL
.Section("ÊÝÕíá").Height = 0.7 * 567
'.Report.Width = 19.8 * 567
'.Section("PageHeadersection").Height = 4.8 * 567
'.Section("Pagefootersection").Height = 2 * 567
.Report.DefaultView = 0
.Report.PopUp = True
.Caption = "ßÔÝ ÑÕÏ ÇáÔåæÑ"
End With
Set txtTextBox = CreateReportControl(rptCustomers.Name, acTextBox, acPageHeader, , "class", 0.5 * 567, 0.2 * 567, 3 * 567, 0.6 * 567)
 txtTextBox.FontSize = 11: txtTextBox.TextAlign = 3
Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageHeader, , , 3.5 * 567, 0.2 * 567, 2 * 567, 0.6 * 567)
lblLabel.Caption = "ÇáÕÜÜÜÝ :": lblLabel.TextAlign = 2: lblLabel.FontSize = 11
Set txtTextBox = CreateReportControl(rptCustomers.Name, acTextBox, acPageHeader, , "gover", 14 * 567, 0.2 * 567, 4 * 567, 0.6 * 567)
 txtTextBox.FontSize = 11: txtTextBox.TextAlign = 3
Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageHeader, , , 18 * 567, 0.2 * 567, 1.8 * 567, 0.6 * 567)
lblLabel.Caption = "ãÍÇÝÙÉ :": lblLabel.TextAlign = 2: lblLabel.FontSize = 11
Set txtTextBox = CreateReportControl(rptCustomers.Name, acTextBox, acPageHeader, , "classroom", 0.5 * 567, 0.8 * 567, 3 * 567, 0.6 * 567)
 txtTextBox.FontSize = 11: txtTextBox.TextAlign = 3
Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageHeader, , , 3.5 * 567, 0.8 * 567, 2 * 567, 0.6 * 567)
lblLabel.Caption = "ÇáÝÕÜÜá :": lblLabel.TextAlign = 2: lblLabel.FontSize = 11
Set txtTextBox = CreateReportControl(rptCustomers.Name, acTextBox, acPageHeader, , "directorate", 14 * 567, 0.8 * 567, 4 * 567, 0.6 * 567)
 txtTextBox.FontSize = 11: txtTextBox.TextAlign = 3
Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageHeader, , , 18 * 567, 0.8 * 567, 1.8 * 567, 0.6 * 567)
lblLabel.Caption = "ÇáÅÏÇÑÉ :": lblLabel.TextAlign = 2: lblLabel.FontSize = 11
Set txtTextBox = CreateReportControl(rptCustomers.Name, acTextBox, acPageHeader, , "school", 14 * 567, 1.4 * 567, 4 * 567, 0.6 * 567)
 txtTextBox.FontSize = 11: txtTextBox.TextAlign = 3
Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageHeader, , , 18 * 567, 1.4 * 567, 1.8 * 567, 0.6 * 567)
lblLabel.Caption = "ÇáãÏÑÓÜÉ :": lblLabel.TextAlign = 2: lblLabel.FontSize = 11
Set txtTextBox = CreateReportControl(rptCustomers.Name, acTextBox, acPageHeader, , "='ÕÝÍÉ' & [Page] & ' ãä ' & [Pages]", 9 * 567, 0, 3 * 567, 0.6 * 567)
 txtTextBox.FontSize = 11: txtTextBox.TextAlign = 3
Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageHeader, , , 2 * 567, 1.9 * 567, 12.5 * 567, 0.8 * 567)
lblLabel.Caption = "  ßÔÝ ÑÕÏ ÏÑÌÇÊ ÇÚãÇá ÇáÓäÉ ááÝÕá ÇáÏÑÇÓí": lblLabel.TextAlign = 3: lblLabel.FontSize = 14: lblLabel.BorderStyle = 1: lblLabel.BorderWidth = 1: lblLabel.BackStyle = 1: lblLabel.BackColor = RGB(211, 211, 211): lblLabel.TopMargin = 0.1 * 567
Set txtTextBox = CreateReportControl(rptCustomers.Name, acTextBox, acPageHeader, , "term", 5.2 * 567, 2 * 567, 1.5 * 567, 0.6 * 567): txtTextBox.BackColor = RGB(211, 211, 211): txtTextBox.FontSize = 14: txtTextBox.TextAlign = 3
Set txtTextBox = CreateReportControl(rptCustomers.Name, acTextBox, acPageHeader, , "year", 2.2 * 567, 2 * 567, 3 * 567, 0.6 * 567):  txtTextBox.BackColor = RGB(211, 211, 211): txtTextBox.FontSize = 14: txtTextBox.TextAlign = 3
For jj = 0 To 2
For ii = 0 To 16
If jj = 0 And (ii < 3) Then: Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageHeader, , , ii * 567, 2.8 * 567, 1 * 567, 1.4 * 567)
If jj = 0 And (ii = 3 Or ii = 7 Or ii = 11) Then: Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageHeader, , , ii * 567, 2.8 * 567, 4 * 567, 0.6 * 567)
If jj = 0 And (ii = 15) Then: Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageHeader, , , ii * 567, 2.8 * 567, 4 * 567, 2 * 567)
If jj = 0 And (ii = 16) Then: Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageHeader, , , 19 * 567, 2.8 * 567, 0.8 * 567, 2 * 567)
If jj = 1 And (ii > 2 And ii < 15) Then: Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageHeader, , , ii * 567, 3.4 * 567, 1 * 567, 0.8 * 567)
If jj = 2 And ii < 15 Then: Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageHeader, , , ii * 567, 4.2 * 567, 1 * 567, 0.6 * 567)
lblLabel.BorderStyle = 1: lblLabel.BorderWidth = 1
If jj = 0 And ii = 0 Then: lblLabel.Caption = "ÊÑã Çæá": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
If jj = 0 And ii = 1 Then: lblLabel.Caption = "ãÊæÓØ ÇáÏÑÌÉ": lblLabel.TextAlign = 2: lblLabel.FontSize = 10: lblLabel.TopMargin = 0.2 * 567
If jj = 0 And ii = 2 Then: lblLabel.Caption = "ÇáãÌãæÚ Çáßáí": lblLabel.TextAlign = 2: lblLabel.FontSize = 9: lblLabel.TopMargin = 0.2 * 567
If jj = 0 And ii = 3 Then: lblLabel.Caption = "ÔåÑ ÏíÓãÈÑ": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
If jj = 0 And ii = 7 Then: lblLabel.Caption = "ÔåÑ äæÝãÈÑ": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
If jj = 0 And ii = 11 Then: lblLabel.Caption = "ÔåÑ ÇßÊæÈÑ": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
If jj = 0 And ii = 15 Then: lblLabel.Caption = "ÇáÇÓÜÜÜÜã": lblLabel.TextAlign = 2: lblLabel.FontSize = 12: lblLabel.TopMargin = 0.6 * 567
If jj = 0 And ii = 16 Then: lblLabel.Caption = "ã": lblLabel.TextAlign = 2: lblLabel.FontSize = 12: lblLabel.TopMargin = 0.6 * 567
If jj = 1 And (ii = 3 Or ii = 7 Or ii = 11) Then: lblLabel.Caption = "ÇáãÌãæÚ": lblLabel.TextAlign = 2: lblLabel.FontSize = 8: lblLabel.TopMargin = 0.2 * 567
If jj = 1 And (ii = 4 Or ii = 8 Or ii = 12) Then: lblLabel.Caption = "ÊÞæíãÇÊ ÔÝåíÉ": lblLabel.TextAlign = 2: lblLabel.FontSize = 9
If jj = 1 And (ii = 5 Or ii = 9 Or ii = 13) Then: lblLabel.Caption = "ãåÇã ÌãÇÚíÉ": lblLabel.TextAlign = 2: lblLabel.FontSize = 9
If jj = 1 And (ii = 6 Or ii = 10 Or ii = 14) Then: lblLabel.Caption = "ãåÇã ÝÑÏíÉ": lblLabel.TextAlign = 2: lblLabel.FontSize = 9
If jj = 2 And (ii = 0) Then: lblLabel.Caption = "100": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
If jj = 2 And (ii = 1) Then: lblLabel.Caption = "70": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
If jj = 2 And (ii = 2) Then: lblLabel.Caption = "210": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
If jj = 2 And (ii = 3 Or ii = 7 Or ii = 11) Then: lblLabel.Caption = "70": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
If jj = 2 And (ii = 4 Or ii = 8 Or ii = 12) Then: lblLabel.Caption = "20": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
If jj = 2 And (ii = 5 Or ii = 9 Or ii = 13 Or ii = 6 Or ii = 10 Or ii = 14) Then: lblLabel.Caption = "25": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
Next
Next
For ii = 0 To 16
If ii < 15 Then: Set txtTextBox = CreateReportControl(rptCustomers.Name, acTextBox, acDetail, , "", ii * 567, 0, 1 * 567, 0.7 * 567): txtTextBox.BorderStyle = 1: txtTextBox.BorderWidth = 1: txtTextBox.FontSize = 11: txtTextBox.TextAlign = 2
If ii = 15 Then: Set txtTextBox = CreateReportControl(rptCustomers.Name, acTextBox, acDetail, , "student_name", ii * 567, 0, 4 * 567, 0.7 * 567): txtTextBox.BorderStyle = 1: txtTextBox.BorderWidth = 1: txtTextBox.FontSize = 11: txtTextBox.TextAlign = 3
If ii = 16 Then: Set txtTextBox = CreateReportControl(rptCustomers.Name, acTextBox, acDetail, , "=1", 19 * 567, 0, 0.8 * 567, 0.7 * 567): txtTextBox.BorderStyle = 1: txtTextBox.BorderWidth = 1: txtTextBox.FontSize = 11: txtTextBox.TextAlign = 2: txtTextBox.RunningSum = 1
Next
For ii = 0 To 3
Set lblLabel = CreateReportControl(rptCustomers.Name, acLabel, acPageFooter, , , (1 * 567) + (ii * 4.5 * 567), 0, 4.5 * 567, 0.6 * 567)
If ii = 0 Then: lblLabel.Caption = "ãÏíÑ ÅÏÇÑÉ ÇáãÏÇÑÓ": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
If ii = 1 Then: lblLabel.Caption = "ãæÌå ÇáãÇÏÉ": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
If ii = 2 Then: lblLabel.Caption = "ÑÆíÓ ÇáÞÓã": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
If ii = 3 Then: lblLabel.Caption = "ãÏÑÓ ÇáÝÕá": lblLabel.TextAlign = 2: lblLabel.FontSize = 12
Next
DoCmd.Save , strReportName
DoCmd.Close
DoCmd.OpenReport "rpt", acViewLayout
 Dim varGroupLevel As Variant
  varGroupLevel = CreateGroupLevel("rpt", "classroom", True, True)
 Reports!rpt.Section(acGroupLevel1Header).Height = 0
Reports!rpt.Section(acGroupLevel1Footer).Height = 0
Reports!rpt.Section(acGroupLevel1Header).ForceNewPage = 1
Reports!rpt.Section("PageHeadersection").Height = 4.8 * 567
Reports!rpt.Section("Pagefootersection").Height = 2 * 567
Reports("rpt").Width = 19.8 * 567
DoCmd.Save , strReportName
DoCmd.Close

DoCmd.OpenReport "rpt", acViewPreview
Reports("rpt").Printer.Orientation = acPRORPortrait
'Reports("rpt").Width = 19.8 * 567
Reports("rpt").Printer.TopMargin = 1 * 567
Reports("rpt").Printer.LeftMargin = 0.5 * 567
Reports("rpt").Printer.RightMargin = 0.5 * 567
Reports("rpt").Printer.PaperSize = acPRPSA4
DoCmd.Maximize


انا اولا بحاول تعلم استخدام vba في انشاء النموذج والتقرير (بحاول اتقان استخدام الاكواد) 

الكود السابق يقوم بانشاء تقرير وفعلا يقوم بانشاؤه باستثناء عملية انشاء group level وعلي فكرة الكود فعال ويتم انشاء group level ولكن تؤثر علي عرض التقرير فهل هذه المشكلة لها حل ام لا

تم تعديل بواسطه jjafferr
وضع الكود بالطريقة الصحيحة بإستخدام <> القائمة
رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information