saya pernah buat, coddingnya seperti ini :
Private Sub cmdadd_click()
'select dulu databasenya
Set rspinjam = New ADODB.Recordset
sqlpinjam = "select * from tPinjam"
rspinjam.Open sqlpinjam, cnn, adOpenKeyset, adLockReadOnly
If Not rspinjam.EOF And Not rspinjam.BOF Then
If Not rspinjam.BOF Then
rspinjam.MoveLast
Text1.Text = rspinjam.Fields("Nomor_Urut").Value + 1
Else
On Error GoTo 0
End If
Else
Text1.Text = 1
End If
text2.setfocus
End sub
Naufal Mumtaz Ramadhan <[EMAIL PROTECTED]> wrote:
coba ganti dengan
If AdoNoUrut.eof = true Then
N = 1
Else
AdoNoUrut.MoveLast
N = AdoNoUrut.Fields("N")
End If
--- mukromin <[EMAIL PROTECTED]> wrote:
> Saya sudah coba isi N = 1 tetap tidak bisa
>
>
>
> ----- Original Message -----
> From: Development, ID-IT
> To: [email protected]
> Sent: Monday, April 30, 2007 10:51 AM
> Subject: RE: [indoprog-vb] Nomor Otomatis
>
>
> Kalau nilai awal N diisi 1 bagaimana?
>
> If AdoNoUrut.RecordCount = 0 Then
> N = 1
> Else
> AdoNoUrut.MoveLast
>
> N = AdoNoUrut.Fields("N")
> End If
> N = N + 1
>
> ________________________________
>
> From: [email protected]
> [mailto:[EMAIL PROTECTED]
> On Behalf Of mukromin
> Sent: Monday, April 30, 2007 10:24 AM
> To: [email protected];
> [EMAIL PROTECTED]
> Subject: [indoprog-vb] Nomor Otomatis
>
> Selamat pagi rekan-rekan semua, saya punya koding
> seperti dibawah.
>
> Sub NoUrut()
> Set AdoNoUrut = New Recordset
> AdoNoUrut.Open "Select Left(Max(tblIn.In_Id),4) As
> N from tblIn", db,
> adOpenStatic, adLockOptimistic
> If AdoNoUrut.RecordCount = 0 Then
> N = 0
> Else
> AdoNoUrut.MoveLast
> N = AdoNoUrut.Fields("N")
> End If
> N = N + 1
> txtNomor.Text = Format(N, "0000") & "-" &
> Format(Now, "MMM-yy") & ("-" &
> "IN" )
> End Sub
>
> Private Sub cmdAdd_Click()
> Call NoUrut
> End Sub
>
> Pada saat cmdAdd diclick nomor otomatis urut ( N +
> 1 ). Masalahnya jika
> tblIn masih kosong nomor tidak otomatis
> menjadi 1. Untuk nomor ke 2 dst tidak masalah.
> Mohon pencerahannya.
> Terima Kasih
>
> Salam
> Mukromin
>
> [Non-text portions of this message have been
> removed]
>
> ----------
>
> This email is confidential. If you are not the
> addressee tell the sender immediately and destroy
> this email
> without using, sending or storing it. Emails are
> not secure and may suffer errors, viruses, delay,
> interception and amendment. Standard Chartered PLC
> and subsidiaries ("SCGroup") do not accept liability
> for
> damage caused by this email and may monitor email
> traffic.
>
> [Non-text portions of this message have been
> removed]
>
>
>
>
>
> [Non-text portions of this message have been
> removed]
>
>
Send instant messages to your online friends http://uk.messenger.yahoo.com
---------------------------------
Shape Yahoo! in your own image. Join our Network Research Panel today!
[Non-text portions of this message have been removed]