73
ห้อง MS Access / : มี Combo box หลายตัว อยู่ในฟอร์ม
« เมื่อ: 10 พ.ค. 62 , 08:12:29 »
นำไปใช้ การลงข้อมูล ชื่อ - ที่อยู่ลูกค้า ครับ
โพสต์นี้ได้รับคำขอบคุณจาก: sjs
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.
Private Sub Combo_Box_1_AfterUpdate()
If Not IsNull(Me.Combo_Box_1) Then
Me.Combo_Box_2 = Me.Combo_Box_1
Me.Combo_Box_3 = Me.Combo_Box_1
End If
End Sub
เราเอา code ไปใส่ใน module ได้ไหมครับ เพราะทุกฟอร์มที่เปิดจะ เปิดใช้เหมือนกัน จะได้ไม่ต้องไใส่ใน form load ของ propertyท่านไปกำหนดของแต่ละฟอร์ม ก่อนเรียก Function มาใช้นะครับ
Public Function MyKeyCode(KeyCode As Integer, Shift As Integer) As Integer
Select Case KeyCode
Case vbKeyF1
MyKeyCode = 0
MsgBox "F2 = Previous Record" & vbCrLf & "F3 = Next Record" & vbCrLf & _
"F4 = Save Record" & vbCrLf & "F8 = Open Reports" & vbCrLf & _
"F10 = Save And Exit", vbInformation + vbSystemModal, "HELP"
Case vbKeyF2
MyKeyCode = 0
On Error Resume Next
DoCmd.GoToRecord , , acPrevious
Case vbKeyF3
MyKeyCode = 0
On Error Resume Next
DoCmd.GoToRecord , , acNext
Case vbKeyF4
MyKeyCode = 0
DoCmd.RunCommand acCmdSaveRecord
Case vbKeyF8
MyKeyCode = 0
DoCmd.OpenReport "Report1", acViewNormal
Case vbKeyF10
DoCmd.Close , , acSaveYes
Case Else
MyKeyCode = KeyCode
End Select
End Function
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
KeyCode = MyKeyCode(KeyCode, Shift)
End Sub
ผมทำ report invoice โดยเชื่อมโยงจาก quiry และทุกครั้งต้องถามเลขที่บิล มีวิธีใดทางลัด ป้อนข้อมูลในฟอร์มขาย สั่งพิมพ์บิลได้เลย ขอคำแนะนำครับreport invoice เชื่อมโยงจาก Query อยู่แล้วมี Field เก็บเลขที่บิลอยู่แล้ว
Private Sub BtnPrint_Click()
DoCmd.SelectObject acForm, “Frm_original”, True
DoCmd.PrintOut , , , , 1
DoCmd.SelectObject acForm, “Frm_Copy”, True
DoCmd.PrintOut , , , , 1
End Sub
เท่านี้ก็จะทำการปริ้น ทั้ง 2 ฟอร์ม โดยไม่ต้องเปิดฟอร์มขึ้นมาก็ได้คับมันคือ Arrays หรือเปล่าครับหรือ
https://docs.microsoft.com/en-us/office/vba/language/concepts/getting-started/using-arrays
[url = "ที่อยู่เว็บ"] ข้อความหรือชื่อเว็บที่ต้องการให้แสดงออกมา [/url]
[url=https://www.thai-access.com/index.php] บอร์ดเรียนรู้ Access สำหรับคนไทย [/url]
https://medium.com/linedevth/%E0%B9%84%E0%B8%A1%E0%B9%88%E0%B8%9E%E0%B8%A5%E0%B8%B2%E0%B8%94%E0%B8%97%E0%B8%B8%E0%B8%81%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%AA%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%AA%E0%B8%B2%E0%B8%A3%E0%B8%81%E0%B8%B1%E0%B8%9A%E0%B8%9C%E0%B8%B9%E0%B9%89%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%9A%E0%B8%A3%E0%B8%B4%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%82%E0%B8%AD%E0%B8%87%E0%B8%84%E0%B8%B8%E0%B8%93-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2%E0%B8%A3%E0%B8%B0%E0%B8%9A%E0%B8%9A%E0%B9%81%E0%B8%88%E0%B9%89%E0%B8%87%E0%B9%80%E0%B8%95%E0%B8%B7%E0%B8%AD%E0%B8%99%E0%B8%9C%E0%B9%88%E0%B8%B2%E0%B8%99-line-notify-a4f8c41cf633
มีแบบส่งรายบุคคลมั้ยครับพี่
Private Sub xxx_KeyPress(KeyAscii As Integer)
If KeyAscii >= 3585 And KeyAscii <= 3675 Then KeyAscii = 0
End Sub
Dim i As Integer
Dim c As String
For i = 1 To Len(Me.Text2)
c = Mid$(Me.Text2, i, 1)
If AscW(c) >= 3585 And AscW(c) <= 3675 Then
MsgBox "Found"
Exit Sub
End If
Next i
Public Function Color_Hex_To_Long(strColor As String) As Long
Dim iRed As Integer
Dim iGreen As Integer
Dim iBlue As Integer
strColor = Replace(strColor, "#", "")
strColor = Right("000000" & strColor, 6)
iBlue = Val("&H" & Mid(strColor, 1, 2))
iGreen = Val("&H" & Mid(strColor, 3, 2))
iRed = Val("&H" & Mid(strColor, 5, 2))
Color_Hex_To_Long = RGB(iRed, iGreen, iBlue)
End Function
Me.Detail.BackColor = RGB("&H" & Left$(s, 2), _
"&H" & Mid$(s, 3, 2), _
"&H" & Right$(s, 2))
Me.Detail.BackColor = "&H" & Right$(s, 2) & Mid$(s, 3, 2) & Left$(s, 2)