0% found this document useful (0 votes)
7 views26 pages

Data Entry and Management Form

The document contains a series of Visual Basic for Applications (VBA) code snippets for managing inventory and unit work data, including functionalities for adding, updating, and deleting records in a database. It features user interface elements such as text boxes and combo boxes to input data, along with confirmation message boxes for actions. The code utilizes ADODB for database connections and operations, ensuring data integrity and user interaction throughout the process.

Uploaded by

yani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views26 pages

Data Entry and Management Form

The document contains a series of Visual Basic for Applications (VBA) code snippets for managing inventory and unit work data, including functionalities for adding, updating, and deleting records in a database. It features user interface elements such as text boxes and combo boxes to input data, along with confirmation message boxes for actions. The code utilizes ADODB for database connections and operations, ensuring data integrity and user interaction throughout the process.

Uploaded by

yani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Private Sub Combo1_Click()

[Link] = True
[Link]
End Sub

Private Sub Command1_Click()


pesan = MsgBox("Apakah Data Barang Akan Disimpan..??", vbQuestion + vbYesNo, "Konfirmasi")
If pesan = vbYes Then
Dim DbPersediaan As [Link]
Dim BARANG As [Link]
Set DbPersediaan = New [Link]
Set BARANG = New [Link]
[Link] = "provider MASDASQL.1;persist security info=false;Data
Source=rudi"
[Link]
Set BARANG = [Link]("insert into barang
(kd_brg,nm_brg,jenis,stok,harga)values('" & [Link] & "','" & [Link] & "','" & [Link] &
"','" & [Link] & "','" & [Link] & "')", DBSQLPassThrough)
[Link]
Tb_Brg.Refresh
Call Form_Load
[Link]
Else
[Link]
End If
End Sub

Private Sub Command2_Click()


Call Form_Load
[Link]
End Sub

Private Sub Command3_Click()


Unload Me
End Sub
Private Sub Form_Load()
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = "--Pilih--"

[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If Tb_Brg.[Link] > 0 Then Tb_Brg.[Link]
cari = "kd_brg = '" & [Link] & "'"
Tb_Brg.[Link] cari
If Tb_Brg.[Link] Then
[Link] = True
[Link] = True
[Link]
Else
MsgBox "Data Barang Sudah Pernah Dimasukkan", vbInformation, "Masukkan Data Baru"
Call Form_Load
[Link]
End If
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = True
[Link]
End If
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = True
[Link]
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
[Link] = Val([Link]) * Val([Link])
[Link] = True
[Link]
End If
End Sub
Private Sub Combo1_Click()
[Link] = True
[Link]
End Sub

Private Sub Command1_Click()


pesan = MsgBox("Apakah Data Barang Akan Diperbaiki..??", vbQuestion + vbYesNo, "Konfirmasi")
If pesan = vbYes Then
Dim DbPersediaan As [Link]
Dim BARANG As [Link]
Set DbPersediaan = New [Link]
Set BARANG = New [Link]
[Link] = "provider MASDASQL.1;persist security info=false;Data
Source=rudi"
[Link]
Set BARANG = [Link]("update barang set nm_brg='" & [Link] & "',jenis='" &
[Link] & "',stok='" & [Link] & "',harga='" & [Link] & "'" & "where kd_brg = '" &
[Link] & "'", DBSQLPassThrough)
[Link]
Tb_Brg.Refresh
Call Form_Load
[Link]
Else
[Link]
End If
End Sub

Private Sub Command2_Click()


Call Form_Load
[Link]
End Sub

Private Sub Command3_Click()


Unload Me
End Sub
Private Sub Form_Load()
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = "--Pilih--"

[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If Tb_Brg.[Link] > 0 Then Tb_Brg.[Link]
cari = "kd_brg = '" & [Link] & "'"
Tb_Brg.[Link] cari
If Not Tb_Brg.[Link] Then
[Link] = Tb_Brg.Recordset("nm_brg")
[Link] = Tb_Brg.Recordset("jenis")
[Link] = Tb_Brg.Recordset("stok")
[Link] = Tb_Brg.Recordset("harga")
[Link] = Val([Link]) * Val([Link])
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
Else
MsgBox "Data Barang Belum Pernah Dimasukkan", vbInformation, "Data Belum Ada"
Call Form_Load
[Link]
End If
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = True
[Link]
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
[Link] = True
[Link]
End If
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = Val([Link]) * Val([Link])
[Link] = True
[Link]
End If
End Sub
Private Sub Combo1_Click()
[Link] = True
[Link]
End Sub

Private Sub Command1_Click()


pesan = MsgBox("Apakah Data Barang Akan Dihapus..??", vbQuestion + vbYesNo, "Konfirmasi")
If pesan = vbYes Then
Dim DbPersediaan As [Link]
Dim BARANG As [Link]
Set DbPersediaan = New [Link]
Set BARANG = New [Link]
[Link] = "provider MASDASQL.1;persist security info=false;Data
Source=rudi"
[Link]
Set BARANG = [Link]("delete from barang where kd_brg = '" & [Link] & "'",
DBSQLPassThrough)
[Link]
Tb_Brg.Refresh
Call Form_Load
[Link]
Else
[Link]
End If
End Sub

Private Sub Command2_Click()


Call Form_Load
[Link]
End Sub

Private Sub Command3_Click()


Unload Me
End Sub
Private Sub Form_Load()
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = "--Pilih--"

[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If Tb_Brg.[Link] > 0 Then Tb_Brg.[Link]
cari = "kd_brg = '" & [Link] & "'"
Tb_Brg.[Link] cari
If Not Tb_Brg.[Link] Then
[Link] = Tb_Brg.Recordset("nm_brg")
[Link] = Tb_Brg.Recordset("jenis")
[Link] = Tb_Brg.Recordset("stok")
[Link] = Tb_Brg.Recordset("harga")
[Link] = Val([Link]) * Val([Link])
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
Else
MsgBox "Data Barang Belum Pernah Dimasukkan", vbInformation, "Data Belum Ada"
Call Form_Load
[Link]
End If
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = True
[Link]
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
[Link] = True
[Link]
End If
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = Val([Link]) * Val([Link])
[Link] = True
[Link]
End If
End Sub
Private Sub Command1_Click()
pesan = MsgBox("Apakah Data Uker Akan Disimpan..??", vbQuestion + vbYesNo, "Konfirmasi")
If pesan = vbYes Then
Dim DbPersediaan As [Link]
Dim TbUker As [Link]
Set DbPersediaan = New [Link]
Set TbUker = New [Link]
[Link] = "provider MSDASQL.1;persist security info=false;data
source=rudi"
[Link]
Set TbUker = [Link]("insert into unit_kerja(no_uker,nama)values('" & [Link] &
"','" & [Link] & "')", DBSQLPassThrough)
[Link]
[Link]
Call Form_Load
[Link]
Else
[Link]
End If
End Sub

Private Sub Command2_Click()


Call Form_Load
[Link]
End Sub

Private Sub Command3_Click()


Unload Me
End Sub

Private Sub Form_Load()


[Link] = ""
[Link] = ""

[Link] = False
[Link] = False
[Link] = False
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If [Link] > 0 Then [Link]
cari = "no_uker = '" & [Link] & "'"
[Link] cari
If [Link] Then
[Link] = True
[Link] = True
[Link]
Else
MsgBox "Data Unit Kerja Sudah Pernah Dimasukkan", vbInformation, "Uker Sudah Ada"
Call Form_Load
[Link]
End If
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = True
[Link]
End If
End Sub
Private Sub Command1_Click()
pesan = MsgBox("Apakah Data Uker Akan Diperbaiki..??", vbQuestion + vbYesNo, "Konfirmasi")
If pesan = vbYes Then
Dim DbPersediaan As [Link]
Dim TbUker As [Link]
Set DbPersediaan = New [Link]
Set TbUker = New [Link]
[Link] = "provider MSDASQL.1;persist security info=false;data
source=rudi"
[Link]
Set TbUker = [Link]("update unit_kerja set nama='" & [Link] & "'" & "where
no_uker = '" & [Link] & "'", DBSQLPassThrough)
[Link]
[Link]
Call Form_Load
[Link]
Else
[Link]
End If
End Sub

Private Sub Command2_Click()


Call Form_Load
[Link]
End Sub

Private Sub Command3_Click()


Unload Me
End Sub

Private Sub Form_Load()


[Link] = ""
[Link] = ""

[Link] = False
[Link] = False
[Link] = False
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If [Link] > 0 Then [Link]
cari = "no_uker = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("nama")
[Link] = True
[Link] = True
[Link] = True
[Link]
Else
MsgBox "Data Unit Kerja Belum Pernah Dimasukkan", vbInformation, "Uker Belum Ada"
Call Form_Load
[Link]
End If
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = True
[Link]
End If
End Sub
Private Sub Command1_Click()
pesan = MsgBox("Apakah Data Uker Akan Dihapus..??", vbQuestion + vbYesNo, "Konfirmasi")
If pesan = vbYes Then
Dim DbPersediaan As [Link]
Dim TbUker As [Link]
Set DbPersediaan = New [Link]
Set TbUker = New [Link]
[Link] = "provider MSDASQL.1;persist security info=false;data
source=rudi"
[Link]
Set TbUker = [Link]("delete from unit_kerja where no_uker = '" & [Link] &
"'", DBSQLPassThrough)
[Link]
[Link]
Call Form_Load
[Link]
Else
[Link]
End If
End Sub

Private Sub Command2_Click()


Call Form_Load
[Link]
End Sub

Private Sub Command3_Click()


Unload Me
End Sub

Private Sub Form_Load()


[Link] = ""
[Link] = ""

[Link] = False
[Link] = False
[Link] = False
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If [Link] > 0 Then [Link]
cari = "no_uker = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("nama")
[Link] = True
[Link] = True
Else
MsgBox "Data Unit Kerja Belum Pernah Dimasukkan", vbInformation, "Uker Belum Ada"
Call Form_Load
[Link]
End If
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = True
[Link]
End If
End Sub
Private Sub Combo1_Click()
[Link] = True
[Link]
End Sub

Private Sub Command1_Click()


pesan = MsgBox("Apakah Transaksi Akan Disimpan..??", vbQuestion + vbYesNo, "Konfirmasi")
If pesan = vbYes Then
[Link]
[Link]!no = [Link]
[Link]!no_uker = [Link]
[Link]!kd_brg = [Link]
[Link]!tgl = [Link]
[Link]!jml = [Link]
[Link]!stat = [Link]
[Link]
[Link]
Call Form_Load
[Link]
Else
[Link]
End If
End Sub

Private Sub Command2_Click()


Call Form_Load
[Link]
End Sub

Private Sub Command3_Click()


Unload Me
End Sub

Private Sub Form_Load()


[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = "//"
[Link] = "##/##/####"
[Link] = "-PILIH-"

[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If [Link] > 0 Then [Link]
cari = "no = '" & [Link] & "'"
[Link] cari
If [Link] Then
[Link] = True
[Link] = True
[Link]
Else
MsgBox "No. Transaksi Sudah Pernah Dimasukkan", vbInformation, "Transaksi Sudah Ada"
Call Form_Load
[Link]
End If
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If [Link] > 0 Then [Link]
cari = "no_uker = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("nama")
[Link] = True
[Link] = True
[Link] = True
[Link]
Else
MsgBox "No. Unit Kerja Tidak Ada", vbInformation, "Masukkan Lagi"
[Link] = ""
[Link]
End If
End If
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If [Link] > 0 Then [Link]
cari = "kd_brg = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("nm_brg")
[Link] = [Link]("harga")
[Link] = True
[Link]
Else
MsgBox "Kode Barang Belum Ada", vbInformation, "Masukkan Lagi"
[Link] = ""
[Link]
End If
End If
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = [Link] * Val([Link])
[Link] = True
[Link]
End If
End Sub

Private Sub Timer1_Timer()


[Link] = Date
End Sub

Private Sub tgl_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = True
[Link]
End If
End Sub
Private Sub Combo1_Click()
[Link] = True
[Link]
End Sub

Private Sub Command1_Click()


pesan = MsgBox("Apakah Transaksi Akan Diperbaiki..??", vbQuestion + vbYesNo, "Konfirmasi")
If pesan = vbYes Then
[Link]
[Link]!no = [Link]
[Link]!no_uker = [Link]
[Link]!kd_brg = [Link]
[Link]!tgl = [Link]
[Link]!jml = [Link]
[Link]!stat = [Link]
[Link]
[Link]
Call Form_Load
[Link]
Else
[Link]
End If
End Sub

Private Sub Command2_Click()


Call Form_Load
[Link]
End Sub

Private Sub Command3_Click()


Unload Me
End Sub

Private Sub Form_Load()


[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = "//"
[Link] = "##/##/####"
[Link] = "-PILIH-"

[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If [Link] > 0 Then [Link]
cari = "no = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("no_uker")
If [Link] > 0 Then [Link]
cari = "no_uker = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("nama")
End If
[Link] = [Link]("tgl")
[Link] = [Link]("stat")
[Link] = [Link]("kd_brg")
If [Link] > 0 Then [Link]
cari = "kd_brg = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("nm_brg")
[Link] = [Link]("harga")
End If
[Link] = [Link]("jml")
[Link] = [Link] * [Link]
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
Else
MsgBox "No. Transaksi Belum Pernah Dimasukkan", vbInformation, "Transaksi Belum Ada"
Call Form_Load
[Link]
End If
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If [Link] > 0 Then [Link]
cari = "no_uker = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("nama")
[Link] = True
[Link] = True
[Link]
Else
MsgBox "No. Unit Kerja Tidak Ada", vbInformation, "Masukkan Lagi"
[Link] = ""
[Link]
End If
End If
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If [Link] > 0 Then [Link]
cari = "kd_brg = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("nm_brg")
[Link] = [Link]("harga")
[Link] = True
[Link]
Else
MsgBox "Kode Barang Belum Ada", vbInformation, "Masukkan Lagi"
[Link] = ""
[Link]
End If
End If
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = [Link] * Val([Link])
[Link] = True
[Link]
End If
End Sub

Private Sub Timer1_Timer()


[Link] = Date
End Sub

Private Sub tgl_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = True
[Link]
End If
End Sub
Private Sub Combo1_Click()
[Link] = True
[Link]
End Sub

Private Sub Command1_Click()


pesan = MsgBox("Apakah Transaksi Akan Diperbaiki..??", vbQuestion + vbYesNo, "Konfirmasi")
If pesan = vbYes Then
[Link]
[Link]
Call Form_Load
[Link]
Else
[Link]
End If
End Sub

Private Sub Command2_Click()


Call Form_Load
[Link]
End Sub

Private Sub Command3_Click()


Unload Me
End Sub

Private Sub Form_Load()


[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = "//"
[Link] = "##/##/####"
[Link] = "-PILIH-"

[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If [Link] > 0 Then [Link]
cari = "no = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("no_uker")
If [Link] > 0 Then [Link]
cari = "no_uker = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("nama")
End If
[Link] = [Link]("tgl")
[Link] = [Link]("stat")
[Link] = [Link]("kd_brg")
If [Link] > 0 Then [Link]
cari = "kd_brg = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("nm_brg")
[Link] = [Link]("harga")
End If
[Link] = [Link]("jml")
[Link] = [Link] * [Link]
[Link] = True
[Link] = True
Else
MsgBox "No. Transaksi Belum Pernah Dimasukkan", vbInformation, "Transaksi Belum Ada"
Call Form_Load
[Link]
End If
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If [Link] > 0 Then [Link]
cari = "no_uker = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("nama")
[Link] = True
[Link] = True
[Link]
Else
MsgBox "No. Unit Kerja Tidak Ada", vbInformation, "Masukkan Lagi"
[Link] = ""
[Link]
End If
End If
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If [Link] > 0 Then [Link]
cari = "kd_brg = '" & [Link] & "'"
[Link] cari
If Not [Link] Then
[Link] = [Link]("nm_brg")
[Link] = [Link]("harga")
[Link] = True
[Link]
Else
MsgBox "Kode Barang Belum Ada", vbInformation, "Masukkan Lagi"
[Link] = ""
[Link]
End If
End If
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = [Link] * Val([Link])
[Link] = True
[Link]
End If
End Sub

Private Sub Timer1_Timer()


[Link] = Date
End Sub

Private Sub tgl_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
[Link] = True
[Link]
End If
End Sub

You might also like