สรุปผลรวมแต่ละหน้า
กระทู้เก่าบอร์ด อ.Yeadram

 10,023   66
URL.หัวข้อ / URL
สรุปผลรวมแต่ละหน้า

รบกวนสอบถาม report อยากให้สรุปยอดแต่ละหน้าครับ

รหัส       ชื่อ        ค่าแรง ชม.ทำงาน    ค่าแรง       OT    ค่ารถ        ยอดสุทธิ
001 นายใจดี     190           8           190        200      80                  470
002 นางสมใจ    200        16          400        180      40                  620
003 นายดีใจ      203        24          609             0      0                    609
                                                            รวม     380     120               1,699
                                                      รวมทั้งสิ้น 380      120              1,699

" รวม " เป็นยอดรวมแต่ละหน้าครับ
" รวมทั้งสิ้น " เป็นยอดรวมหน้าสุดท้ายครับ
ตอนนี้ผมทำได้แต่ยอดรวมหน้าสุดท้ายครับ

66 Reply in this Topic. Dispaly 4 pages and you are on page number 1

1 @R12149
2 @R12177
คุณสันติสุข ผมพิมพ์ถูกต้องหรือเปล่าครับ พอผม run ดูแล้ว หน้าแรกผลรวมถูกต้องครับ แต่พอหน้าที่ 2 มันเอายอดผลรวมหน้าแรกมาแสดงครับ
ขอรบกวนขออีกครั้งครับ


Option Compare Database
Dim x As Double

Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
Me!pagesum = Me!runsum - x
x = Me!runsum

End Sub


Private Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)
x = 0
End Sub
3 @R12178
โค้ดไม่มีอะไรผิด คุณลองเช็คดูครับว่า property ต่างๆที่เขาบอกเอาไว้ในลิงค์ที่ให้ไป มีอันไหนกำหนดไม่ตรงกับที่เขาบอกหรือเปล่า
4 @R12180
ทำยังไงให้ runsum โชว์ที่หน้าสุดท้ายต่อจาก pagesum ได้ครับ
ผลรวมแต่ละหน้า
        รวม :           pagesum

ผลรวมหน้าสุดท้าย
          รวม :           pagesum
รวมทั้งสิ้น :           runsum

pagesum ผมทำได้แล้ว โชว์ผลรวมแต่ละหน้า
แต่ runsum ก็โชว์ทุกหน้าเลยครับ
5 @R12181
Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
Me!pagesum = Me!runsum - x
x = Me!runsum
Me!runsum.Visible = (Me.Page = Me.Pages)
End Sub
6 @R12182
เพิ่มเติมข้อมูลแล้ว แต่ก็ยังเหมือนเดิมครับ
อีกอย่างครับ ผมได้ยอดรวม ค่าแรง แล้ว ยอดรวม Ot - ค่ารถ - ยอดสุทธิ
ต้องทำยังไงต่อครับ
    รหัส       ชื่อ        ค่าแรง ชม.ทำงาน    ค่าแรง       OT    ค่ารถ        ยอดสุทธิ
001 นายใจดี     190           8           190        200      80                  470
002 นางสมใจ    200        16          400        180      40                  620
003 นายดีใจ      203        24          609             0      0                    609
                                                            รวม     380     120               1,699
                                                      รวมทั้งสิ้น 380      120              1,699
7 @R12184
ไม่เข้าใจครับ

- "เพิ่มเติมข้อมูลแล้ว" ? ข้อมูลอะไรครับ แล้วเกี่ยวยังไงกับปัญหาที่เกิดขึ้นถึงนำมาเพิ่ม

- "ได้ยอดรวม ค่าแรง แล้ว ยอดรวม Ot - ค่ารถ - ยอดสุทธิ ต้องทำยังไงต่อครับ" ? จะทำอะไรครับ
8 @R12185
ผมเพิ่มตาม R12181 แล้วครับ
แล้วผมจะเอาหน้า ตย.มา post ในกระทู้นี้ ต้องทำยังไงครับ
9 @R12188
อ๋อ อ่านแล้วงงเลย

สร้างเท็กซ์บ็อกซ์ 2 ตัวที่ Page Header section นะครับ ตัวนึงกำหนด Control Source property เป็น =[Page] อีกตัวเป็น =[Pages] แล้วให้ Visible property ของทั้ง 2 ตัวเป็น No

ลองดูครับว่าจะแก้ปัญหาได้หรือไม่

ปล. การโพสรูปภาพ ให้คลิกปุ่มที่เป็นรูปรปุภาพที่มีลูกศรชี้ขึ้น (รูปที่ 2 จากขวาสุด) จะได้วินโดว์เล็กๆเพื่อเลือกไฟล์ ให้ขยายวินโดว์นี้ให้ใหญ่ครอบคลุมทุกตัว จะเห็นปุ่ม Browse แล้วก็ทำตามขั้นตอนที่โปรแกรมบอกไว้ครับ
10 @R12196


ขอโทษด้วยครับที่ทำให้งง
จากภาพด้านบนนะครับ
คือผมต้องให้รายงานมีผลรวมแต่ละหน้าตามนั้นครับ ที่ผมทำได้ตอนนี้คือ ผลรวม " ค่าจ้างรับ " แต่ละหน้าได้แล้ว แต่ช่อง (ล่วงเวลา) (ค่ารถค่ากะ) ไปจนถึงช่อง (รับสุทธิ) ต้องทำยังไงต่อครับ รบกวนอีกครั้งครับ
11 @R12197


นี่คือผลรวมหน้าแรกครับ
ผลรวมแรกคือ pagesum
ผลรวมที่ 2 คือ runsum

           ถ้า runsum ผมจะให้ไปโชว์ที่หน้าสุดท้ายที่เดียวเลยได้หรือไม่ครับ(หน้าสุดท้ายจะโชว์บรรทัดแรก pagesum บรรทัดที่ 2 runsum ครับ)
12 @R12198
- ผมว่าตามที่ผมตอบในคำตอบที่ (R12188) น่าจะแก้ปัญหาให้พิมพ์ RunSum ที่หน้าสุดท้ายไม่ได้หรือ ?

- ส่วนการหาผลรวมของคอลัมน์อื่นๆนั้น คุณก็ทำแบบเดียวกัน เพียงแต่แต่ละคอลัมน์ที่ต้องการหาผลรวมนั้น ต้องมี PageSum, RunSum และ X เป็นของตัวเองครับ อาจตั้งชื่อ PageSum_OT, RunSum_OT, X_OT ก็ได้เพื่อให้เข้าใจง่าย แล้วก็เพิ่มโค้ดสำหรับแต่ละคอลัมน์เข้าไปในโปรแกรมด้วยครับ
13 @R12199
คุณสันติสุข ช่วยดูโค้ดให้ด้วยครับ ผมทำตาม R12198 แล้วครับ ตอนนี้มียอดผลรวมโชว์ขึ้นมาแล้วครับ แต่ว่า ยอดรวม pagesum เท่ากับ Runsum ทุกหน้าเลยครับ( pagesum= ผลรวมแต่ละหน้า , runsum= ผลรวมทุกหน้า แต่โชว์ที่หน้าสุดท้าย แต่ ณ ตอนนี้ runsum ออกมาทุกหน้าเลยครับ)

Option Compare Database
Dim x As Double

Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
Me!pagesum_sumofj = Me!RunSum_sumofj - x_sumofj
x = Me!RunSum_sumofj
Me!RunSum_sumofj.Visible = (Me.Page = Me.Pages)
Me!pagesum_sumofj1 = Me!runsum_sumofj1 - x_sumofj1
x = Me!runsum_sumofj1
Me!runsum_sumofj1.Visible = (Me.Page = Me.Pages)
Me!pagesum_j4 = Me!RunSum_j4 - x_j4
x = Me!RunSum_j4
Me!RunSum_j4.Visible = (Me.Page = Me.Pages)
Me!pagesum_j5 = Me!RunSum_j5 - x_j5
x = Me!RunSum_j5
Me!RunSum_j5.Visible = (Me.Page = Me.Pages)
Me!pagesum_s = Me!RunSum_s - x_s
x = Me!RunSum_s
Me!RunSum_s.Visible = (Me.Page = Me.Pages)
Me!pagesum_d = Me!runsum_d - x_d
x = Me!runsum_d
Me!runsum_d.Visible = (Me.Page = Me.Pages)
Me!pagesum_p = Me!runsum_p - x_p
x = Me!runsum_p
Me!runsum_p.Visible = (Me.Page = Me.Pages)
Me!pagesum_tu = Me!runsum_tu - x_tu
x = Me!runsum_tu
Me!runsum_tu.Visible = (Me.Page = Me.Pages)
Me!pagesum_o = Me!runsum_o - x_o
x = Me!runsum_o
Me!runsum_o.Visible = (Me.Page = Me.Pages)
Me!pagesum_t = Me!runsum_t - x_t
x = Me!runsum_t
Me!runsum_t.Visible = (Me.Page = Me.Pages)
Me!pagesum_t1 = Me!runsum_t1 - x_t1
x = Me!runsum_t1
Me!runsum_t1.Visible = (Me.Page = Me.Pages)
Me!pagesum_pa = Me!runsum_pa - x_pa
x = Me!runsum_pa
Me!runsum_pa.Visible = (Me.Page = Me.Pages)
Me!pagesum_n = Me!runsum_n - x_n
x = Me!runsum_n
Me!runsum_n.Visible = (Me.Page = Me.Pages)
Me!pagesum_t2 = Me!runsum_t2 - x_t2
x = Me!runsum_t2
Me!runsum_t2.Visible = (Me.Page = Me.Pages)
End Sub
Private Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)
x = 0
End Sub

14 @R12200
คุณมีแต่ Dim x As Double ไม่มี x_sumofj , x_sumofj1 , ...
15 @R12201
แล้วคุณก็มีแต่ x = 0 ด้วย ตัวอื่นไม่มี
16 @R12202
แบบนี้ใช้แบบที่ต้องการหรือเปล่า
http://office.microsoft.com/th-th/access-help/HA001122444.aspx

ดูแล้วน่าจะง่ายกว่าหรือเปล่า
17 @R12203
Option Compare Database
Dim x As Double
Dim x_sumofj As Double
Dim x_sumofj1 As Double
Dim x_sumofj4 As Double
Dim x_sumofj5 As Double
Dim x_sumofs As Double
Dim x_sumofd As Double
Dim x_sumofp As Double
Dim x_sumoftu As Double
Dim x_sumofo As Double
Dim x_sumoft As Double
Dim x_sumoft1 As Double
Dim x_sumofpa As Double
Dim x_sumofn As Double
Dim x_sumoft2 As Double

Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
Me!pagesum_sumofj = Me!RunSum_sumofj - x_sumofj
x = Me!RunSum_sumofj
Me!RunSum_sumofj.Visible = (Me.Page = Me.Pages)
Me!pagesum_sumofj1 = Me!runsum_sumofj1 - x_sumofj1
x = Me!runsum_sumofj1
Me!runsum_sumofj1.Visible = (Me.Page = Me.Pages)
Me!pagesum_j4 = Me!RunSum_j4 - x_j4
x = Me!RunSum_j4
Me!RunSum_j4.Visible = (Me.Page = Me.Pages)
Me!pagesum_j5 = Me!RunSum_j5 - x_j5
x = Me!RunSum_j5
Me!RunSum_j5.Visible = (Me.Page = Me.Pages)
Me!pagesum_s = Me!RunSum_s - x_s
x = Me!RunSum_s
Me!RunSum_s.Visible = (Me.Page = Me.Pages)
Me!pagesum_d = Me!runsum_d - x_d
x = Me!runsum_d
Me!runsum_d.Visible = (Me.Page = Me.Pages)
Me!pagesum_p = Me!runsum_p - x_p
x = Me!runsum_p
Me!runsum_p.Visible = (Me.Page = Me.Pages)
Me!pagesum_tu = Me!runsum_tu - x_tu
x = Me!runsum_tu
Me!runsum_tu.Visible = (Me.Page = Me.Pages)
Me!pagesum_o = Me!runsum_o - x_o
x = Me!runsum_o
Me!runsum_o.Visible = (Me.Page = Me.Pages)
Me!pagesum_t = Me!runsum_t - x_t
x = Me!runsum_t
Me!runsum_t.Visible = (Me.Page = Me.Pages)
Me!pagesum_t1 = Me!runsum_t1 - x_t1
x = Me!runsum_t1
Me!runsum_t1.Visible = (Me.Page = Me.Pages)
Me!pagesum_pa = Me!runsum_pa - x_pa
x = Me!runsum_pa
Me!runsum_pa.Visible = (Me.Page = Me.Pages)
Me!pagesum_n = Me!runsum_n - x_n
x = Me!runsum_n
Me!runsum_n.Visible = (Me.Page = Me.Pages)
Me!pagesum_t2 = Me!runsum_t2 - x_t2
x = Me!runsum_t2
Me!runsum_t2.Visible = (Me.Page = Me.Pages)
End Sub
Private Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)
x = 0
x=j
x=j1
x=j4
x=j5
x=s
x=d
x=p
x=tu
x=o
x=t
x=t1
x=pa
x=n
x=t2
End Sub
แบบนี้ใช่หรือไม่ครับ
18 @R12204
Option Compare Database
Dim x As Double
Dim x_sumofj As Double
Dim x_sumofj1 As Double
Dim x_j4 As Double
Dim x_j5 As Double
Dim x_s As Double
Dim x_d As Double
Dim x_p As Double
Dim x_tu As Double
Dim x_o As Double
Dim x_t As Double
Dim x_t1 As Double
Dim x_pa As Double
Dim x_n As Double
Dim x_t2 As Double

Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
Me!pagesum_sumofj = Me!RunSum_sumofj - x_sumofj
x = Me!RunSum_sumofj
Me!RunSum_sumofj.Visible = (Me.Page = Me.Pages)
Me!pagesum_sumofj1 = Me!runsum_sumofj1 - x_sumofj1
x = Me!runsum_sumofj1
Me!runsum_sumofj1.Visible = (Me.Page = Me.Pages)
Me!pagesum_j4 = Me!RunSum_j4 - x_j4
x = Me!RunSum_j4
Me!RunSum_j4.Visible = (Me.Page = Me.Pages)
Me!pagesum_j5 = Me!RunSum_j5 - x_j5
x = Me!RunSum_j5
Me!RunSum_j5.Visible = (Me.Page = Me.Pages)
Me!pagesum_s = Me!RunSum_s - x_s
x = Me!RunSum_s
Me!RunSum_s.Visible = (Me.Page = Me.Pages)
Me!pagesum_d = Me!runsum_d - x_d
x = Me!runsum_d
Me!runsum_d.Visible = (Me.Page = Me.Pages)
Me!pagesum_p = Me!runsum_p - x_p
x = Me!runsum_p
Me!runsum_p.Visible = (Me.Page = Me.Pages)
Me!pagesum_tu = Me!runsum_tu - x_tu
x = Me!runsum_tu
Me!runsum_tu.Visible = (Me.Page = Me.Pages)
Me!pagesum_o = Me!runsum_o - x_o
x = Me!runsum_o
Me!runsum_o.Visible = (Me.Page = Me.Pages)
Me!pagesum_t = Me!runsum_t - x_t
x = Me!runsum_t
Me!runsum_t.Visible = (Me.Page = Me.Pages)
Me!pagesum_t1 = Me!runsum_t1 - x_t1
x = Me!runsum_t1
Me!runsum_t1.Visible = (Me.Page = Me.Pages)
Me!pagesum_pa = Me!runsum_pa - x_pa
x = Me!runsum_pa
Me!runsum_pa.Visible = (Me.Page = Me.Pages)
Me!pagesum_n = Me!runsum_n - x_n
x = Me!runsum_n
Me!runsum_n.Visible = (Me.Page = Me.Pages)
Me!pagesum_t2 = Me!runsum_t2 - x_t2
x = Me!runsum_t2
Me!runsum_t2.Visible = (Me.Page = Me.Pages)
End Sub
Private Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)
x = 0
x=j
x=j1
x=j4
x=j5
x=s
x=d
x=p
x=tu
x=o
x=t
x=t1
x=pa
x=n
x=t2
End Sub
แก้ไขตรง Dim x ครับ
19 @R12205
มันต้อง
x_sumofj = 0
x_sumofj1 = 0
...
...
...

ไม่ใช่
x=j
x=j1
...
...
...


และต้อง
x_sumofj = Me!RunSum_sumofj
...
x_sumofj1 = Me!runsum_sumofj1
...

ไม่ใช่
x = Me!RunSum_sumofj
...
x = Me!runsum_sumofj1
...
20 @R12206
ได้แล้วครับ ขอขอบคุณมากมายเลยครับ(ยิ้มออกเลยเรา)


อีกนิดครับ ตามรูป runsum(วงเล็บสีแดง) ยังขึ้นมาทุกหน้าเลยครับ


ตามรูปนะครับ ถ้าต้องการให้ทั้ง pagesum และ runsum ขึ้นไปชิดกับบรรทัดสุดท้ายของหน้าได้หรือไม่ครับ
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.2687s