แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Looktarn

หน้า: [1]
1
รบกวนสอบถามนะคะ
เนื่องจากมีความต้องการดึงข้อมูลจากตารางมาคำนวณ
แต่ติดปัญหาว่าหากมีการแก้ไขการคำนวณรอบที่ 2 (แก้ไขข้อมูลทั้งๆที่ยังไม่ได้ save) มันจะดึงข้อมูลผลลัพธ์จากการคำนวณครั้งที่ 1 มาคำนวณต่อส่งผลให้ผลลัพธ์คลาดเคลื่อนได้
เช่น ต้องการดึง Doxorubicin2 จากตาราง AC_regimen
เดิม Doxorubicin2 จากตาราง =78
หากใส่ Doseadjust=80 จะได้ผลลัพธ์เท่ากับ  78*80/100 = 62.4
แต่หากมีการแก้ไข Doseadjust = 90 จะได้ผลลัพธ์คือ 62.4*90/100 = 56.16 แต่สิ่งที่อยากได้คือ 78*90/100=70.2
ขณะนี้ใช้สูตร
Doxorubicin2 = DLookup(Doxorubicin2, "AC_regimen") * TextDoseadjust1 / 100
อยากให้ DLookup(Doxorubicin2, "AC_regimen") เป็นข้อมุลจากตารางโดยตรงไม่เปลี่ยนแปลงจนกว่าเราจะกด save นะคะ

รบกวนท่านผู้รู้ทีนะคะ ขอบคุณมากๆเลยค่ะ



(ทั้งนี้มีการใส่สูตรไม่ให้บันทึกจนกว่าจะกด save ไปแล้ว แต่ก็ยังดึงข้อมูล current มา
Private Sub Form_Error(DataErr As Integer, Response As Integer)
IsSaveClicked = False
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Cancel = Not IsSaveClicked


End Sub
Private Sub Form_AfterUpdate()
IsSaveClicked = False

End Sub)

2
รบกวนสอบถามนะคะ การ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   

3
รบกวนเรียนสอบถามนะคะ
่ลูกตาลเป็นมือใหม่ ไม่เคยเรียนหรือทำ access มาก่อนเลย ที่ทำขณะนี้คือศึกษาหาจาก google และ youtube เอา ตอนนี้กำลังทำโปรแกรม 1 โปรแกรมอยู่นะคะ แต่ติดปัญหาอยู่ 3 อย่าง ทำมาหลายเดือนแล้วไม่ได้สักที เลยจะมาขอความช่วยเหลือจากพี่ๆที่ thai-accessช่วยเหลือทีนะคะ
ปัญหาคือ
1. เวลา Form_Load เราอยากให้เป็นหน้าที่ข้อมูล Blank ๆนะคะ เลยใส่สูตร
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec

End Sub
(ทีนี้พบปัญหาเวลาที่เราไปเลือกข้อมูลเก่ามาแก้ไข มันก็จะadd new ตลอดเวลาในข้อมูล table อยากให้มันเซฟข้อมูลเฉพาะเวลาเรากรอกรายละเอียดข้อมูลนะคะ จะต้องทำอย่างไร)
2. เวลาเราเลือกข้อมูลมาแก้ไข จะพบปัญหาคือ (มักจะต้องมีการ search ข้อมูลเก่ามาแก้ไข)
หากใช้สูตร DoCmd.RunCommand acCmdSaveRecord พอเรากดเซฟข้อมูลที่เรากรอกจะหายไป
เลยเปลี่ยนมาเป็น DoCmd.GoToRecord  พอกดเซฟมันจะเซฟข้อมูล แต่ข้อมูลในบรรทัดถัดไปของ table จะหายไป
เลยเปลี่ยนมาเป็น DoCmd.GoToRecord , , acNewRec พอกดเซฟข้อมูลจะถูกเซฟ และข้อมูลในบรรทัดถัดไปของ table ยังอยู่ แต่จะมี new data มาใหม่เยอะมาก  (เลยอยากให้ saveเฉพาะที่การเลือกมาแก้ไขข้อมูลนะคะ)

3. เราได้สร้าง form ใหม่เพื่อให้ add รายละเอียดคนไข้รายใหม่เข้าไปนะคะ แต่อยากให้มันไปปรากฏในหน้า form ด้วยจะสามารถทำได้ไหมคะ

ขอบคุณมากๆเลยนะคะ :love: :love: :love:

หน้า: [1]