รบกวนสอบถามนะคะ การprint กรณี ทำ full screen


0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

17 ธ.ค. 61 , 09:39:17
อ่าน 1101 ครั้ง

Looktarn

รบกวนสอบถามนะคะ การprint กรณี ทำ full screen
 เนื่องด้วยได้มีการทำ form แล้วตอนนี้ทำให้มัน pop up แบบ full screen แล้วมีการปรับเนื้อหาให้อยู่ตรงกลางจอภาพ
เมื่อกดปริ้นมันจะปริ้นเป็น 2 แผ่น คือ แผ่นที่1 ด้านซ้ายของจอ แผ่นที่ 2 ด้านขวาของจอ (รูปที่แนบมาด้วย 1.ภาพจากหน้าจอ 2. ภาพเวลาสั่งปริ้นด้านซ้าย 3. ภาพเวลาสั่งปริ้นด้านขวา)
อยากจะทราบว่ามีวิธีทำอย่างไรให้ปริ้นเฉพาะเนื้อหาที่เราต้องการ(อยากให้ปริ้นให้เนื้อหาอยู่ในหน้าเดียวอะคะ)

ปล.เป็นมือใหม่หัดทำ (ไม่มีความรู้พื้นฐานเลย) การเขียนโค๊ดคือการพยายามsearch ในส่วนที่ต้องการ แล้วคัดลอกมา
นี้คือส่วนที่คัดลอกให้มันอยู่ตรงกลางจอ
Private Sub Form_Resize()
'Should run every time the form is resized
    Call CenterControls
End Sub
Private Sub Form_Current()
  'Will run when the form is completing its initialization
   DoCmd.Maximize   'Maximizes the form when first initialized. Omit if required.
   Call CenterControls
End Sub
Sub CenterControls()

'Find the control that has the farthest left position, and the one with the farthest right position.
'That will give us the total distance of our buttons. We will then have to compare that to the width of the form, and move our controls accordingly.
Dim Ctrl As Control
Dim ClosestLeft As Integer
Dim FurthestRight As Integer
Dim FurthestRightWidth As Integer
Dim GrandTotalWidth As Integer
Dim AmountToMove As Integer
Dim TypicalPosition As Integer


'Finds the furthest left position of all of our controls on the form.
For Each Ctrl In Me
    If ClosestLeft > Ctrl.Left Or ClosestLeft = 0 Then
        ClosestLeft = Ctrl.Left
    End If

'Finds the furthest right control. Also takes the width of that furthest right control (necessary for the calculation)
    If FurthestRight < Ctrl.Left Or FurthestRight = 0 Then
        FurthestRight = Ctrl.Left
        FurthestRightWidth = Ctrl.Width
    End If
Next

'Now we find the grand total width of all of our controls. Furthest Right - Furthest Left + FurthestRightWidth
GrandTotalWidth = FurthestRight - ClosestLeft + FurthestRightWidth

'Finds the typical position of where the left side of the group of controls should sit on the form.
TypicalPosition = (Me.InsideWidth / 2) - (GrandTotalWidth / 2)

'Figures out the amount we'd have to move the group of controls to get them to sit in their typical position.
AmountToMove = TypicalPosition - ClosestLeft

For Each Ctrl In Me
    If Not ClosestLeft + AmountToMove <= 0 Then
        Ctrl.Left = Ctrl.Left + AmountToMove
    End If
Next


End Sub

รูปที่ 1 
รูปที่ 2   
รูปที่ 3   
« แก้ไขครั้งสุดท้าย: 17 ธ.ค. 61 , 21:45:44 โดย Looktarn »

 

17 ธ.ค. 61 , 22:05:13
ตอบกลับ #1

pizza_p

: รบกวนสอบถามนะคะ การprint กรณี ทำ full screen
« ตอบกลับ #1 เมื่อ: 17 ธ.ค. 61 , 22:05:13 »
แนะนำให้สร้าง report แล้ว copy เอาคอนโทรลในฟอร์มไปไว้ใน report แทนครับ ใน report เราสามารถควบคุมการจัดพิมพ์ได้ดีกว่าครับ

 
โพสต์นี้ได้รับคำขอบคุณจาก: Looktarn

18 ธ.ค. 61 , 17:52:41
ตอบกลับ #2

สันติสุข

: รบกวนสอบถามนะคะ การprint กรณี ทำ full screen
« ตอบกลับ #2 เมื่อ: 18 ธ.ค. 61 , 17:52:41 »
ผมคิดว่า มันไม่ได้เกี่ยวกับโค้ด แต่น่าจะเกี่ยวกับการตั้งขอบซ้ายขวาของกระดาษมากกว่านะครับ
ช่วยพกถุงผ้า/ถุงพลาสติกใช้แล้วไปซื้อของเพื่อลดการใช้พลาสติก ขยะ รักษาสิ่งแวดล้อม และไม่ให้ภาวะโลกร้อนวิกฤติเร็วขึ้นกว่านี้
ช่วยคลิกโฆษณาข้างล่างนี้ เพื่อสนับสนุนเวปบอร์ดด้วยครับ
:nice day:
 
โพสต์นี้ได้รับคำขอบคุณจาก: sjs, Looktarn


บอร์ดเรียนรู้ Access สำหรับคนไทย


 

Sitemap 1 2 3 4 5