กด F1=radio0,F2=radio2
กระทู้เก่าบอร์ด อ.Yeadram

 1,678   5
URL.หัวข้อ / URL
กด F1=radio0,F2=radio2

เรียนถามเรื่อง
กด F1=radio0,F2=radio2
คือ ผมทำระบบบันทึกข้อมูล
โดย มี Radio 4 ตัว ให้เลือก
โดย
กด F1 ให้เลือก radio1 ค่า=1
กด F2 ให้เลือก radio2 ค่า=2
กด F3 ให้เลือก radio3 ค่า=3
กด F4 ให้เลือก radio2 ค่า=4

เพื่อความสะดวกในการ key ข้อมูล เพราะจะได้กรอกข้อมูลที่ txtbox แค่ตัวเดียว
โดยไ่ม่ต้องมาคลิกเลือก radio1-radio4

พิมพ์ที่ txtbox แล้ว enter ให้ insert ข้อมูล แล้ว add new record ต่อ

ช่วยแนะนำวิธีหน่อยครับ


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

1 @R02338
F1, F2 เป็น "แป้นพิมพ์ลัดส่วนกลาง" ของ แอคเซสครับ
ใช้ทำอย่างอื่นไม่ได้ (หรือได้นะ อิอิ ไม่แน่ใจ)
F1 ใช้เปิด help
F2 ใช้เปลี่ยนชื่อ หรือใช้ขยายช่องสำหรับใส่นิพจน์
2 @R02386
ได้อ??ู่นะครับ
ผมเคย Download มา
ก็เลยอยากรู้น่ะครับ
3 @R02387
http://www.thaiware.com/main/info.php?id=9308

4 @R02388
อนุญาติท่าน **yeadram** นะครับ ไม่รู้ว่าใช่ แบบนี้มั๊ย

http://www.databaselessons.com/function-key-shortcuts.php


Function Key Shortcuts

A default command button on an Access form works by being clicked with a mouse. I have worked with a number of clients over the years that do massive amounts of data entry using Access, and do not want to remove their hands from the keyboard. This tip shows how to allow keyboard Function Keys to emulate the click, thus leaving fingers on the keyboard.

NOTE: All the VBA code segments on the Database Lessons site assume that you have DAO references active. If you are not sure what this means, and you are using Microsoft Access 2000 or higher, click here.

    * on a form with a command button, change the form's "Key Preview" property to "Yes"
    * make sure the command button has a VBA "On Click" event
    * create an "On Key Down" event for the form
    * put code like this in the "On Key Down" event procedure

     Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

   If KeyCode = vbKeyF5 Then
      KeyCode = 0
      cmdSomeButton_Click
   End If

End Sub

The above example allows the F5 function key to emulate the click of the cmdSomeButton command button. Make sure that you replace "cmdSomeButton" with the actual name of the command button.

This technique can also be used in situations without the command button.

Oh, by the way, if you want to know the proper "names" of other keys, besides function keys, go into the MS Access VBA help screen, and search for "Keycode Constants".
5 @R02389
ถ้าสร้างฟอร์มเปล่า 1 ตัว ไม่มีคอนโทรล
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
msgbox "keycode = " & keycode
End sub

เมื่อเปิดฟอร์ม แล้วกดปุ่มใดๆ มันจะมีปฎิกิริยาตอบรับด้วยการขึ้น msgbox มาบอก


แล้วต่อมาเราเริ่มวางคอนโทรลต่างๆ ลงไปในฟอร์มนี้ ไม่ว่าจะเป็น textbox combobox listbox subform
ทีนี้ลองรันฟอร์ม แล้วกด คีย์ใดๆ ผมจำได้ว่า มันไม่มีปฎิกิริยาตอบรับใดๆ เลย ผมสันนิษฐานว่า
เพราะทันที่ที่เราเปิดฟอร์ม เคอร์เซอร์มันไปโฟกัสอยู่ที่ คอนโทรลแล้ว (คอนโทรลอะไรก็ได้ที่อนุญาตให้ Tabstop) ดังนั้นเหตุการณ์ Form_KeyDown จึงถูกข้ามไปแล้ว

แล้วเราจะไปฝังโค้ดรอรับการกด F1, F2 ไว้ที่คอนโทรลตัวไหนดี?
หรือ....
เมื่อมีคอนโทรลในฟอร์มแล้ว ทำอย่างไรจะจะให้เกิดเหตุการณ์ Form_Keydown ได้อีก?

ผมจำได้ว่าผมเคยลองผิดลองถูกอยู่พักหนึ่งเหมือนกัน แต่ติดตรงสองคำถามดังกล่าวแหละครับ เลยเลิกไป
จริงๆ เวลาคีย์ข้อมูลผมก็ไม่ค่อยจะใช้เมาส์หรอกครับ ผมจะใช้ TAB, Enter มากกว่า ถ้าเจอ radiobox หรือ checkbox ผมก็จะใช้การเคาะ Spacebar เข้าช่วย ส่วนเวลาเขียนฟอร์มเอง ทุกปุ่มคำสั่งจะใส่ & นำหน้าตัวอักษรไว้ครับ เพื่อให้ผู้ใช้กดปุ่ม alt+ตัวอักษรนั้นได้ เลยดังนั้นทั้งโปรแกรมของผม สามารถทำงานได้ตลอดทุกๆ งานแม้เมาส์จะเสีย

-เดินหน้า TAB
-ถอยหลัง shift+TAB
-สลับฟอร์ม ctl+F6
-ปิดฟอร์ม ใช้ ctl+F4
-ปิดโปรแกรมใช้ Alt+F4
-กับ tab control การเปลี่ยนแท็บ ใช้ ctl+TAB
-เลือกแท็บย้อนหลังใช้ ctl+shift+TAB
-เจอคอมโบ กด F4
-อยู่ใน subform จะออกมาที่ mainform ใช้ ctl+shift+TAB
ยังมีอีกหลายๆ ปุ่มที่ใช้บ่อยครับ ส่วนใหญ่ผมเปิดดูจาก help แหละครับ
ctl+down
ctl+pagedown
ฯลฯ


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