Public Sub Sub_serialNo()
Dim rs_tmp12 As New ADODB.Recordset
Dim STR_PVNO As String
Set rs_tmp12 = Nothing
rs_tmp12.Open "Select prefix from VoucherTypeMst where Name='JOURNAL VOUCHER'", conn, adOpenDynamic, adLockOptimisti c
If Not rs_tmp12.EOF Then
STR_PVNO = BRANCHCODE & rs_tmp12(0) & Format(MONTH(Da te), "00") & Format(Day(Date ), "00")
End If
If rs_tmp12.State = adStateOpen Then rs_tmp12.Close
rs_tmp12.Open "Select right(max(Vouch erno),3) from VoucherMst where VoucherType='JO URNAL VOUCHER' and Voucherdate='" & Format(Date, "mm/dd/yyyy") & "' AND Branchcode='" & BRANCHCODE & "' AND LEFT(VOUCHERNO, 3)='" & BRANCHCODE & "' and len(voucherno)= 12 and autogen>0", conn, adOpenDynamic, adLockOptimisti c
If IsNull(rs_tmp12 (0)) Then
STR_PVNO = STR_PVNO & Format(1, "000")
Else
STR_PVNO = STR_PVNO & Format(Val(rs_t mp12(0)) + 1, "000")
End If
VNO = STR_PVNO
End Sub
Dim rs_tmp12 As New ADODB.Recordset
Dim STR_PVNO As String
Set rs_tmp12 = Nothing
rs_tmp12.Open "Select prefix from VoucherTypeMst where Name='JOURNAL VOUCHER'", conn, adOpenDynamic, adLockOptimisti c
If Not rs_tmp12.EOF Then
STR_PVNO = BRANCHCODE & rs_tmp12(0) & Format(MONTH(Da te), "00") & Format(Day(Date ), "00")
End If
If rs_tmp12.State = adStateOpen Then rs_tmp12.Close
rs_tmp12.Open "Select right(max(Vouch erno),3) from VoucherMst where VoucherType='JO URNAL VOUCHER' and Voucherdate='" & Format(Date, "mm/dd/yyyy") & "' AND Branchcode='" & BRANCHCODE & "' AND LEFT(VOUCHERNO, 3)='" & BRANCHCODE & "' and len(voucherno)= 12 and autogen>0", conn, adOpenDynamic, adLockOptimisti c
If IsNull(rs_tmp12 (0)) Then
STR_PVNO = STR_PVNO & Format(1, "000")
Else
STR_PVNO = STR_PVNO & Format(Val(rs_t mp12(0)) + 1, "000")
End If
VNO = STR_PVNO
End Sub