อาจารย์สุภาพครับ จะเขียน Code Acc97 อย่างไรให้รันหมายเลขใบinvoiceครับ
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 316   2
URL.หัวข้อ / URL
อาจารย์สุภาพครับ จะเขียน Code Acc97 อย่างไรให้รันหมายเลขใบinvoiceครับ

ผมอยากให้ run เป็นแบบนี้ครับ 
เลขที่  001-01-46,002-01-46,003-01-46 
พอขี้นเดือนใหม่ก็เป็น 001-02-46,002-02-46 
 
เขียน code อย่างไงดีครับ  

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

1 @R01081
สมมติว่าตารางเป้าหมายชื่อ tblSell16 และฟีลด์ชื่อ ID จากโค้ดข้างล่างจะเป็นการคลิก 2 ทีที่ Text Box ชื่อ ID ใน Form เพื่อให้ออกเลขที่ให้อัตโนมัติ Private Sub ID_DblClick(Cancel As Integer) Dim strMonth As String, strYr As String, intMax As Integer strMonth = Format(Date, "MM") strYr = Format(Date, "BB") If Me.ID = "" Or IsNull(Me.ID) Then If DCount("Val(Mid([ID],2))", "tblSell16", "Mid([ID],5,2) = '" & _ strMonth & "' And Right([ID],2) = '" & strYr & "'") = 0 Then Me.ID = "001-" & Format(strMonth, "00") & "-" & Format(strYr, "00") Else intMax = DMax("Val(Left([ID],3))", "tblSell16", "Mid([ID],5,2) = '" & _ strMonth & "' And Right([ID],2) = '" & strYr & "'") Me.ID = Format(intMax + 1, "000") & "-" & Format(strMonth, "00") & "-" & Format(strYr, "00") End If End If End Sub
2 @R01082
ขอบคุณมากครับ
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.0705s