Materi ini adalah lanjutan dari form barang yang sudah dibuat sebelumnya.
Form diatas menggunakan SSTAB. Silahkan ditambah komponen dengan cara CTRL+T
Dan cari Microsoft Tabbed Dialog Control SP06
Ini sisi tab keduanya
Listingnya:
Private Sub add_Click()
aktif
bersih
tkode_customer.SetFocus
save.Enabled = True
cancel.Enabled = True
add.Enabled = False
edit.Enabled = True
hapus.Enabled = True
End Sub
Private Sub akhir_Click()
data_customer.Recordset.MoveLast
tampil
End Sub
Private Sub awal_Click()
data_customer.Recordset.MoveFirst
tampil
End Sub
Private Sub cancel_Click()
x = MsgBox("Yakin untuk membatalkan penginputan?", vbYesNo, "INFO")
If x = vbYes Then
Call nonaktif
Call bersih
edit.Enabled = False
hapus.Enabled = True
save.Enabled = False
End If
End Sub
Sub bersih()
tkode_customer.Text = ""
tnama_customer.Text = ""
tnomer.Text = ""
talamat.Text = ""
End Sub
Sub aktif()
tkode_customer.Enabled = True
tnama_customer.Enabled = True
tnomer.Enabled = True
talamat.Enabled = True
add.Enabled = True
tcari.Enabled = True
End Sub
Sub nonaktif()
tkode_customer.Enabled = False
tnama_customer.Enabled = False
tnomer.Enabled = False
talamat.Enabled = False
save.Enabled = False
edit.Enabled = False
hapus.Enabled = False
End Sub
Private Sub edit_Click()
data_customer.Recordset.edit
aktif
tkode_customer.Enabled = False
tnama_customer.SetFocus
edit.Enabled = False
save.Enabled = True
hapus.Enabled = True
cancel.Enabled = True
Call tampil
End Sub
Private Sub exit_Click()
a = MsgBox("YAKIN MAU KELUAR?", vbYesNo, "INFO")
If a = vbYes Then
Unload Me
Menu.Show
End If
End Sub
Sub tampil()
With data_customer.Recordset
tkode_customer.Text = !kode_customer
tnama_customer.Text = !nama_customer
tnomer.Text = !telepon
talamat.Text = !alamat
End With
End Sub
Private Sub find_Click()
data_customer.Recordset.Index = "kode_customer"
data_customer.Recordset.Seek "=", tcari
If data_customer.Recordset.NoMatch Then
MsgBox "DATA TIDAK DITEMUKAN", vbOKOnly, "INFORMASI"
data_customer.Recordset.MoveFirst
tcari.Text = ""
tcari.SetFocus
Else
tampil
End If
End Sub
Private Sub Form_Load()
nonaktif
bersih
save.Enabled = False
cancel.Enabled = False
End Sub
Private Sub hapus_Click()
data_customer.Recordset.Delete
data_customer.Recordset.MoveFirst
Call tampil
End Sub
Private Sub maju_Click()
data_customer.Recordset.MoveNext
If data_customer.Recordset.EOF Then
MsgBox "Data sudah di akhir record", vbInformation, "info"
data_customer.Recordset.MoveLast
End If
Call tampil
End Sub
Private Sub mundur_Click()
data_customer.Recordset.MovePrevious
If data_customer.Recordset.BOF Then
MsgBox "Data sudah di awal record", vbInformation, "info"
data_customer.Recordset.MoveFirst
End If
Call tampil
End Sub
Private Sub save_Click()
With data_customer.Recordset
.Index = "kode_customer"
.Seek "=", tkode_customer.Text
If .NoMatch Then
.AddNew
.Fields!kode_customer = tkode_customer.Text
.Fields!nama_customer = tnama_customer.Text
.Fields!telepon = tnomer.Text
.Fields!alamat = talamat.Text
.Update
MsgBox "data tersimpan!", vbInformation, "info"
Else
.edit
.Fields!nama_customer = tnama_customer.Text
.Fields!telepon = tnomer.Text
.Fields!alamat = talamat.Text
.Update
MsgBox "data diperbarui!", vbInformation, "info"
End If
bersih
nonaktif
add.Enabled = True
save.Enabled = False
cancel.Enabled = False
End With
End Sub
Private Sub Timer1_Timer()
tanggal.Caption = Date
jam.Caption = Time
tanggal.Caption = Format(Now, "dddd, dd - mm - yyyy")
End Sub
Private Sub tkode_customer_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
tnama_customer.SetFocus
End If
End Sub
Private Sub tnama_customer_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
tnomer.SetFocus
End If
End Sub
Private Sub tnomer_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
talamat.SetFocus
End If
End Sub
Tidak ada komentar:
Posting Komentar