แสดงกระทู้

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 - supachai

หน้า: [1]
1
รบกวนนะครับ ผมสร้าง combobox โดยกำหนดค่าไว้ เมื่อเปลี่ยนก็ให้สร้าง เร็คคอร์ดใหม่ตามเลขที่กำหนดไว้ครับ
Code ตามนี้ครับ
Private Sub Deptref_Change()

Dim intMax As Variant
Dim strWhere As String
If Me.ID = "" Or IsNull(Me.ID) Then
   strWhere = Me.Deptref + "-" + Right(bYear(Date), 2) + Format(Date, "mm")
   intMax = DMax("ID", "Cases", "ID Like '" + strWhere + "*' ")
   If IsNull(intMax) Then
      Me.ID = strWhere + "-001"
   Else
      Me.ID = strWhere + "-" + Format$(Val(Right(intMax, 3)) + 1, "000")
   End If
   End If
     
End Sub
ลอง copy code จากที่่อื่น มาลองทำดูนะครับ

หน้า: [1]