ต้องการไม่ให้ Form ทำงาน


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

05 พ.ค. 63 , 09:56:24
อ่าน 612 ครั้ง

Krathok-man

ต้องการไม่ให้ Form ทำงาน
« เมื่อ: 05 พ.ค. 63 , 09:56:24 »
ผมสร้าง code ดังนี้  เพื่อไม่ให้ Form BB_detail  รับข้อมูล
 [BB_detail].Form.AllowAdditions = False
 [BB_detail].Form.AllowEdits = False
 [BB_detail].Form.AllowDeletions = False
แต่มันยังกด command btt  ได้  จริงๆ  ผมอยากให้ Disable ทั้งหมด คือสั่งอะไรไม่ได้เลย
เมื่อเกิดเหตุการณ์    มีวิธีอะไรบ้างครับ

 

05 พ.ค. 63 , 10:19:55
ตอบกลับ #1

PNR

: ต้องการไม่ให้ Form ทำงาน
« ตอบกลับ #1 เมื่อ: 05 พ.ค. 63 , 10:19:55 »
ผมสร้าง code ดังนี้  เพื่อไม่ให้ Form BB_detail  รับข้อมูล
 [BB_detail].Form.AllowAdditions = False
 [BB_detail].Form.AllowEdits = False
 [BB_detail].Form.AllowDeletions = False
แต่มันยังกด command btt  ได้  จริงๆ  ผมอยากให้ Disable ทั้งหมด คือสั่งอะไรไม่ได้เลย
เมื่อเกิดเหตุการณ์    มีวิธีอะไรบ้างครับ

ใช้การกำหนด ControlType ครับเช่นต้องการให้ combobox , textbox , commandbotton ไม่ให้สามารถกดแก้ไขได้ ใช้ ctl.Enabled = false

โค๊ด: [Select]
Private Sub Form_Current()
Dim ctl As Control
  For Each ctl In Me
   If ctl.ControlType = acComboBox Then
       ctl.Enabled = False
       ctl.Locked = True
   End If
    If ctl.ControlType = acTextBox Then
       ctl.Enabled = False
       ctl.Locked = True
   End If
    If ctl.ControlType = acCommandButton Then
       ctl.Enabled = False
          End If
         Next ctl
    Forms![BB_detail].Form.AllowAdditions = False
    Forms![BB_detail].Form.AllowEdits = False
    Forms![BB_detail].Form.AllowDeletions = False
End Sub

ControlType แบบต่างๆ
   acBoundObjectFrame      Bound object frame   
   acCheckBox      Check box   
   acComboBox      Combo box   
   acCommandButton      Command button   
   acCustomControl      ActiveX (custom) control   
   acImage      Image   
   acLabel      Label   
   acLine      Line   
   acListBox      List box   
   acObjectFrame      Unbound object frame or chart   
   acOptionButton      Option button   
   acOptionGroup      Option group   
   acPage      Page   
   acPageBreak      Page break   
   acRectangle      Rectangle   
   acSubform      Subform/subreport   
   acTabCtl      Tab   
   acTextBox      Text box   
   acToggleButton      Toggle button   


Time to stop for me  :dizzy:
 
โพสต์นี้ได้รับคำขอบคุณจาก: Krathok-man


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


 

Sitemap 1 2 3 4 5