Gimana kalau dibuat Function saja. Contoh dibawah ini

Function GetNewNoInventaris() As String
Dim rsComputer As New ADODB.Recordset
Dim tmpNo As Double
    rsComputer.ActiveConnection = cnMaintenance
    rsComputer.Open "SELECT MAX(No_Inventaris) AS NewNoInventaris FROM
Komputer", , adOpenForwardOnly
    If Not rsComputer.EOF Then
        rsComputer.MoveFirst
        GetNewNoInventaris = IIf(IsNull(rsComputer("NewNoInventaris")), "",
rsComputer("NewNoInventaris"))
        If Trim(GetNewNoInventaris) <> "" Then
            tmpNo = CDbl(Left$(GetNewNoInventaris, 4)) + 1
        Else
            tmpNo = 1
        End If
        GetNewNoInventaris = Right$("0000" & tmpNo, 4) & "/IT-INV/" &
Format$(Now, "yyyy")
    End If
    txtNoInventaris = GetNewNoInventaris
    rsComputer.Close
    Set rsComputer = Nothing
End Function



On 4/30/07, mukromin <[EMAIL PROTECTED]> wrote:
>
>   Saya sudah coba isi N = 1 tetap tidak bisa
>
> ----- Original Message -----
> From: Development, ID-IT
> To: [email protected] <indoprog-vb%40yahoogroups.com>
> 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] <indoprog-vb%40yahoogroups.com> [mailto:
> [email protected] <indoprog-vb%40yahoogroups.com>]
> On Behalf Of mukromin
> Sent: Monday, April 30, 2007 10:24 AM
> To: [email protected] <indoprog-vb%40yahoogroups.com>;
> [EMAIL PROTECTED] <Programmer-VB%40yahoogroups.com>
> 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]
>
> 
>


[Non-text portions of this message have been removed]

Kirim email ke