dear abet,

coba pake prosedur ini ya, caranya tau kan tinggal call NoOtomatis,
maka otomatis juga deh nomernya.
puas...puas...puas  hehehehe ketawa donk masa cuma si tukul aja yg ketawa.
ok perhatiin ya kodingnya, sesuaikan dgn objek2 yg ada di form km ya
disini sy asumsikan km pake dateTimePicker utk input field Tglnya.

'-------------------------------------------------------------
Private Sub NoOtomatis()

Dim rs As ADODB.Recordset
Dim sql, noUrut As String
Dim NoBukti, NoInvoice As String

    vBln = Format(DateTimePicker.Value, "mm") 'ambil bulanya
    vThn = Format(DateTimePicker.Value, "yy") 'ambil tahunnya
    vTgl = "%" & vThn & vBln    'sama dgn %thnbln
  
  Set rs = New ADODB.Recordset
  sql = "SELECT nourut FROM nmTabel WHERE nourut LIKE '" & vTgl & "' ORDER BY 
nourut"
  
  rs.Open sql, cn, adOpenDynamic, adLockOptimistic, adCmdText
  
    If rs.RecordCount = 0 Then 
        txtNoUrut.Text = "AMJ" & vThn & vBln & "0001" 'isi dgn AMJthnbln0001
        noBukti = "AMJ" & vThn & vBln & "0001" 'simpan di variabel
    Else
        rs.MoveLast
        noBukti = rs!nourut
        
        If Right(noBukti, 4) = "0001" Then
            txtNoUrut.Text = "AMJ" & vThn & vBln & "0002"
        Else
            NoInvoice = Right(noBukti, 4) 'ambil 4 digit dari var noBukti
            NoInvoice = NoInvoice + 1          'dari 4 digit tambahkan dg 1
            If Len(NoInvoice) = 1 Then      'jika panjangnya 1
                NoInvoice = "000" & NoInvoice  'isi dgn 0001
                ElseIf Len(NoInvoice) = 2 Then NoInvoice = "00" & NoInvoice
                ElseIf Len(NoInvoice) = 3 Then NoInvoice = "0" & NoInvoice
             End If
            NoBukti = "AMJ" & sThn & sBln & NoInvoice
            txtNoUrut.Text = NoBukti
        End If
    End If
  Set rs = Nothing
End Sub


ok bet di coba ya kalo berhasil katakan pada dunia dg senyuman hehehe...


salam
lis

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Kirim email ke