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

เริ่มโดย Krathok-man, 05 พ.ค. 20 , 09:56:24

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

Krathok-man

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

PNR

อ้างถึงจาก: Krathok-man ใน 05 พ.ค. 20 , 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 ทั้งหมด คือสั่งอะไรไม่ได้เลย
เมื่อเกิดเหตุการณ์    มีวิธีอะไรบ้างครับ

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

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