Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Kode

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Private Sub UserForm_Activate()

Dim Ws As Worksheet
Set Ws = Worksheets(“DATABASE”)
TxtNOMOR.SetFocus
End Sub

‘menyimpan data
Private Sub cmdINPUT_Click()
Dim iRow As Long
Dim Ws As WorkSheets(“DATABASE”)

‘menemukan baris kosong pada database


iRow = Ws.Cells(Rows.Count, 1) _
.End(xlUp).offset(1, 0).Row
‘Cek untuk sebuah kode
If Trim(Me.txtNOMOR.Value) = “” Then
Me.txtNOMOR.SetFocus
MsgBox “TIDAK MENGOSONGKAN NOMOR URUT”
Exit Sub
End If

‘menemukan nomor yang sama


Data = Me.txtNOMOR.Value
With Worksheets(“DATABASE”).Range(“A3:A100.000”)
Set C = .Find(Data, LookIn:=xlFormulas)
If C Is Nothing Then
MsgBox “CEK NOMOR URUT IS OKE”
Else
MsgBox “NOMOR URUT SUDAH ADA”
Me.txtNOMOR.Value = “’
Me.txtNOMOR.SetFocus
Exit Sub
End If
End With

‘copy data ke database


Ws.Cells(iRow, 1).Value = Me.txtNOMOR.Value
Ws.Cells(iRow, 2).Value = Me.txtNAMA.Value
Ws.Cells(iRow, 3).Value = Me.txtKAMPUNG.Value
Ws.Cells(iRow, 4).Value = Me.txtRTRW.Value
Ws.Cells(iRow, 5).Value = Me.cmbKECAMATAN.Value
Ws.Cells(iRow, 6).Value = Me.cmbDESAKELURAHAN.Value
Ws.Cells(iRow, 7).Value = Me.ckLAKILAKI.Value
Ws.Cells(iRow, 8).Value = Me.ckPEREMPUAN.Value
Ws.Cells(iRow, 9).Value = Me.cmbPENDIDIKAN.Value
Ws.Cells(iRow, 10).Value = Me.cmbKESEHATAN.Value
Ws.Cells(iRow, 11).Value = Me.cmbDAYABELI.Value

‘clear data
Me.txtNOMOR.Value = ‘’
Me.txtNAMA.Value = ‘’
Me.txtKAMPUNG.Value = ‘’
Me.txtRTRW.Value = ‘’
Me.cmbKECAMATAN.Value = ‘’
Me.cmbDESAKELURAHAN.Value = ‘’
Me.ckLAKILAKI.Value = ‘’
Me.ckPEREMPUAN.Value = “
Me.cmbPENDIDIKAN.Value = ‘’
Me.cmbKESEHATAN.Value = ‘’
Me.cmbDAYABELI.Value = ‘’
Me.txtNOMOR.SetFocus
MsgBox “DATA SUDAH DI ENTRY KE DATABASE”
End Sub

Private Sub

You might also like