Private Sub Text185_DblClick(Cancel As Integer)
Dim strDate As String
Dim intNum As Integer, intMax As Integer
Dim strSuffix As String
strDate = "IV2" & "" & (Format(date, "yy-mm-dd"))
If Me.voucher_s_id = "" Or IsNull(Me.voucher_s_id) Then
If IsNull(DMax("Val(Mid([voucher_s_id],13))", "voucher_s", "Left([voucher_s_id],11) = '" & strDate & " '")) Then
Me.voucher_s_id = strDate & "-" & "01"
Debug.Print "1"
Else
intMax = DMax("Val(Mid([voucher_s_Id],13))", "voucher_s", "Left([voucher_s_id],11) = '" & strDate & " '")
intMax = intMax + 1
Me.voucher_s_id = strDate & "-" & Format(intMax, "00")
Debug.Print "1"
End If
End If
End Sub
Sub ForIsOtherday()
Dim strDate As String
Dim intNum As Integer, intMax As Integer
Dim strSuffix As String
strDate = "IV2" & "" & (Format(date_sale, "yy-mm-dd"))
If Me.voucher_s_id = "" Or IsNull(Me.voucher_s_id) Then
If IsNull(DMax("Val(Mid([voucher_s_id],12))", "voucher_s", "Left([voucher_s_id],10) = '" & strDate & " '")) Then
Me.voucher_s_id = strDate & "-" & "01"
Debug.Print "1"
Else
intMax = DMax("Val(Mid([voucher_s_Id],12))", "voucher_s", "Left([voucher_s_id],10) = '" & strDate & " '")
intMax = intMax + 1
Me.voucher_s_id = strDate & "-" & Format(intMax, "00")
Debug.Print "1"
End If
End If
End Sub
Private Sub Text185_Enter()
'Private Sub bill_no_Enter()
Dim strDate As String
Dim intNum As Integer, intMax As Integer
Dim strSuffix As String
strDate = "IV2" & "" & (Format(date, "yy-mm-dd"))
If Me.voucher_s_id = "" Or IsNull(Me.voucher_s_id) Then
If IsNull(DMax("Val(Mid([voucher_s_id],12))", "voucher_s", "Left([voucher_s_id],10) = '" & strDate & " '")) Then
Me.voucher_s_id = strDate & "-" & "01"
Debug.Print "1"
Else
intMax = DMax("Val(Mid([voucher_s_Id],12))", "voucher_s", "Left([voucher_s_id],10) = '" & strDate & " '")
intMax = intMax + 1
Me.voucher_s_id = strDate & "-" & Format(intMax, "00")
Debug.Print "1"
End If
End If
End Sub
Private Sub voucher_s_id_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub voucher_s_id_DblClick(Cancel As Integer)
Dim strDate As String
Dim intNum As Integer, intMax As Integer
Dim strSuffix As String
strDate = "IV2" & "" & (Format(date, "yy-mm-dd"))
If Me.voucher_s_id = "" Or IsNull(Me.voucher_s_id) Then
If IsNull(DMax("Val(Mid([voucher_s_id],10))", "voucher_s", "Left([voucher_s_id],10) = '" & strDate & " '")) Then
Me.voucher_s_id = strDate & "-" & "01"
Debug.Print "1"
Else
intMax = DMax("Val(Mid([voucher_s_Id],10))", "voucher_s", "Left([voucher_s_id],10) = '" & strDate & " '")
intMax = intMax + 1
Me.voucher_s_id = strDate & "-" & Format(intMax, "00")
Debug.Print "1"
End If
End If
End Sub
Private Sub voucher_s_id_Enter()
'Private Sub bill_no_Enter()
Dim strDate As String
Dim intNum As Integer, intMax As Integer
Dim strSuffix As String
strDate = "IV2" & "" & (Format(date, "yy-mm-dd"))
If Me.voucher_s_id = "" Or IsNull(Me.voucher_s_id) Then
If IsNull(DMax("Val(Mid([voucher_s_id],10))", "voucher_s", "Left([voucher_s_id],10) = '" & strDate & " '")) Then
Me.voucher_s_id = strDate & "-" & "01"
Debug.Print "1"
Else
intMax = DMax("Val(Mid([voucher_s_Id],10))", "voucher_s", "Left([voucher_s_id],10) = '" & strDate & " '")
intMax = intMax + 1
Me.voucher_s_id = strDate & "-" & Format(intMax, "00")
Debug.Print "1"
End If
End If
End Sub
************
เพิ่มเงื่อนไข
จาก code นี้เลขบิลที่ได้จาก voucher_s_id จะเป็น IV2YY-MM-DD-01 รันนิ่ง 02..03.. อ้างอิงตาม date_sale
เรียน อจ จะเพิ่มโค๊ด "กดปุ่ม" ถามว่าเป็น สำนักงานใหญ่ (เลข 1) หรือสาขา (เลข 2) ถ้าเป็น สำนักงานใหญ่ เลขที่บิล จะเป็นชุด IV1YY-MM-DD-01 ถ้าเป็นสาขา เลขที่บิล จะเป็นชุด IV2YY-MM-DD-01