207
« เมื่อ: 02 พ.ค. 62 , 16:59:37 »
ทำไมรวน เลขที่บิลไม่ running ย่ำอยู่กับเลขเดิม อจ.ช่วยกรุณาชี้จุดทีครับ ผมทำตาราง voucher 1 ตางราง แล้วสร้างฟอร์มบันบิล ทั้งขาย(IVปป-ดด-วว-xx) ทั้งค่าใช้จ่าย(PAปป-ดด-วว-xx) ค่าใช้จ่ายไม่มี VAT (PANVปป-ดด-วว-xx) และมีการบันทึกบิลย้อนหลัง เดือน กพ เพราะไม่ได้บันทึกแบบวันต่อวัน *****ปัญหาคือเลขย่ำอยู่กับที่ครับแต่ รูปแบบบิลได้ครับ)
Private Sub Text89_Click()
Dim StrVoucher_date As String
Dim StrtoDay As String
If Not IsNull(Me.Voucher_date) Then
StrVoucher_date = Format(Voucher_date, "DD/MM/YY")
StrtoDay = Format(Now, "DD/MM/YY")
If StrVoucher_date = StrtoDay Then
Call ForIsToday
Else
Call ForIsOtherday
End If
End If
End Sub
Sub ForIsToday()
Dim strDate As String
Dim intNum As Integer, intMax As Integer
Dim strSuffix As String
strDate = "PANV" & "" & (Format(Now, "yy-mm-dd"))
If Me.voucher_id = "" Or IsNull(Me.voucher_id) Then
If IsNull(DMax("Val(Mid([voucher_id],10))", "voucher", "Left([Voucher_id],10) = '" & strDate & " '")) Then
Me.voucher_id = strDate & "-" & "01"
Debug.Print "1"
Else
intMax = DMax("Val(Mid([Voucher_Id],10))", "voucher", "Left([Voucher_id],10) = '" & strDate & " '")
intMax = intMax + 1
Me.voucher_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 = "PANV" & "" & (Format(Voucher_date, "yy-mm-dd"))
If Me.voucher_id = "" Or IsNull(Me.voucher_id) Then
If IsNull(DMax("Val(Mid([Voucher_id],10))", "voucher", "Left([Voucher_id],10) = '" & strDate & " '")) Then
Me.voucher_id = strDate & "-" & "01"
Debug.Print "1"
Else
intMax = DMax("Val(Mid([Voucher_Id],10))", "voucher", "Left([Voucher_id],10) = '" & strDate & " '")
intMax = intMax + 1
Me.voucher_id = strDate & "-" & Format(intMax, "00")
Debug.Print "1"
End If
End If
End Sub