Kamis, 06 Desember 2012

0 Kamis, (06/12/2012)


Jangan Lupa Tinggalkan Komentar Kalian Ya...!!!
Hari ini saya bisa membuat Auto Number dengan Kombinasi tanggal, bulan, tahun. . .

-----------------------------------------------------------------

Public Function Number(ByVal srcSQL As String, ByVal srcFields As String, ByVal srcFormat As String, Optional srcTrue As Boolean, Optional srcTanggal As Date)
  buka
    Dim rs         As New Recordset
    Dim noLalu, noBaru  As String
    
    Set rs = Nothing
    rs.CursorLocation = adUseClient
    rs.Open srcSQL, Cn, adOpenStatic, adLockReadOnly
    If rs.EOF Then
        If srcTrue = True Then
            Number = "01" & "/" & Format(Now, "dd") & "-" & Format(Now, "MM") & Format(Now, "yy") & srcFormat
        Else
            Number = "01" & "/" & Format(Now, "dd") & "-" & Format(Now, "MM") & Format(Now, "yy") & srcFormat
        End If
    Else
        If srcTrue = True Then
            noLalu = Val(Left(rs.Fields(srcFields), 2) + 1)
            noBaru = String(2 - Len(noLalu), "0") & noLalu
            Number = noBaru & "/" & Format(Now, "dd") & "-" & Format(Now, "MM") & Format(Now, "yy") & srcFormat
            'MsgBox "no berikutnya " & noBaru
        Else
            noLalu = Val(Left(rs.Fields(srcFields), 2) + 1)
            noBaru = String(2 - Len(noLalu), "0") & noLalu
            Number = noBaru & "/" & Format(Now, "dd") & "-" & Format(Now, "MM") & Format(Now, "yy") & srcFormat
            'MsgBox "no berikutnya 2 " & noBaru
        End If
    End If
    
    Set rs = Nothing
    
End Function
-----------------------------------------------------------------
Pemangilannya.. .

txtkuitansi = Number("Select top 20 no_kws from data order by no_kws desc", "no_kws", "/Ry.AdmPrakerin", False)

-----------------------------------------------------------------

semoga berhasil....
Good Luck....


0 komentar:

Posting Komentar