0% found this document useful (0 votes)
9 views2 pages

VBA UserForm Data Entry Guide

The VBA code defines macros to activate a user form and submit data from the form to a database worksheet. When the form loads, it sets focus to the TxtNOMOR text box. The cmdINPUT_Click macro finds the next empty row, checks if the form number already exists, copies the form data to the database if unique, clears the form fields, and notifies the user that the data was entered. It prevents duplicate numbers and empty required fields.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

VBA UserForm Data Entry Guide

The VBA code defines macros to activate a user form and submit data from the form to a database worksheet. When the form loads, it sets focus to the TxtNOMOR text box. The cmdINPUT_Click macro finds the next empty row, checks if the form number already exists, copies the form data to the database if unique, clears the form fields, and notifies the user that the data was entered. It prevents duplicate numbers and empty required fields.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Private Sub UserForm_Activate()

Dim Ws As Worksheet
Set Ws = Worksheets(“DATABASE”)
[Link]
End Sub

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

‘menemukan baris kosong pada database


iRow = [Link]([Link], 1) _
.End(xlUp).offset(1, 0).Row
‘Cek untuk sebuah kode
If Trim([Link]) = “” Then
[Link]
MsgBox “TIDAK MENGOSONGKAN NOMOR URUT”
Exit Sub
End If

‘menemukan nomor yang sama


Data = [Link]
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”
[Link] = “’
[Link]
Exit Sub
End If
End With

‘copy data ke database


[Link](iRow, 1).Value = [Link]
[Link](iRow, 2).Value = [Link]
[Link](iRow, 3).Value = [Link]
[Link](iRow, 4).Value = [Link]
[Link](iRow, 5).Value = [Link]
[Link](iRow, 6).Value = [Link]
[Link](iRow, 7).Value = [Link]
[Link](iRow, 8).Value = [Link]
[Link](iRow, 9).Value = [Link]
[Link](iRow, 10).Value = [Link]
[Link](iRow, 11).Value = [Link]

‘clear data
[Link] = ‘’
[Link] = ‘’
[Link] = ‘’
[Link] = ‘’
[Link] = ‘’
[Link] = ‘’
[Link] = ‘’
[Link] = “
[Link] = ‘’
[Link] = ‘’
[Link] = ‘’
[Link]
MsgBox “DATA SUDAH DI ENTRY KE DATABASE”
End Sub

Private Sub

You might also like