Design Form
Atur Properties :
Name : DataSup
Databasename : <
Recordset Type : 0 - Table
RecordSource : Supplier
Visible : False
Name : DbGrid1
DataSource : DataSup
Listing Program
' Pencarian data atau record dengan method seek
Dim Mkodesup As String * 6
Sub siapisi()
'objek berfungsi untuk siap isiMe.txtkode.Enabled = True
Me.txtnama.Enabled = True
Me.txtalamat.Enabled = True
Me.txtkota.Enabled = True
Me.txttelp.Enabled = True
End Sub
Sub tdksiapisi()Me.txtkode.Enabled = False
Me.txtnama.Enabled = False
Me.txtalamat.Enabled = False
Me.txtkota.Enabled = False
Me.txttelp.Enabled = False
End Sub
Sub bersih()Me.txtkode.Text = ""
Me.txtnama.Text = ""
Me.txtalamat.Text = ""
Me.txtkota.Text = ""
Me.txttelp.Text = ""
End Sub
Private Sub cmdbatal_Click()tdksiapisi
bersih
Me.cmdbatal.Enabled = False
Me.cmdkeluar.Enabled = True
Me.cmdtambah.Enabled = True
Me.cmdsimpan.Enabled = False
End Sub
Private Sub cmdbrowse_Click()
' Jumlah karakter nama masukanDim panjang As String
Mkodesup = InputBox(" Ketik Kode Suplier :")
' Cari data yang kode barangnya sama dengan MKodebrgMe.DataSup.Recordset.Seek "=", Mkodesup
If Me.DataSup.Recordset.NoMatch Then
Response = MsgBox("data Tidak Ditemukan!", vbInformation, "Pencarian Kode Supplier")
End If
End Sub
Private Sub cmdedit_Click()
'mengaktifkan textboxMe.txtnama.Enabled = True
Me.txtalamat.Enabled = True
Me.txtkota.Enabled = True
Me.txttelp.Enabled = True
'mentidakaktifkan commboboxMe.cmdtambah.Enabled = False
Me.cmdhapus.Enabled = False
Me.cmdbrowse.Enabled = False
Me.cmdedit.Enabled = False
'mengaktifkan tombolMe.cmdupdate.Enabled = True
End Sub
Private Sub cmdhapus_Click()
'perintah menghapus record dataDim X As Byte
X = MsgBox(" Betul akan dihapus ?", vbOKCancel, "mengahapus record")
If X = vbOK Then
Me.DataSup.Recordset.Delete
Me.DataSup.Recordset.MoveNext
If Me.DataSup.Recordset.EOF Then
Me.DataSup.Recordset.MoveLast
End If
End If
bersih
tdksiapisi
End Sub
Private Sub cmdkeluar_Click()Unload Me
End Sub
Private Sub cmdsimpan_Click()
'Menyimpan Data dalam databaseMe.DataSup.Recordset.AddNew
Me.DataSup.Recordset!kodesup = Me.txtkode.Text
Me.DataSup.Recordset!namasup = Me.txtnama.Text
Me.DataSup.Recordset!alamat = Me.txtalamat.Text
Me.DataSup.Recordset!kota = Me.txtkota.Text
Me.DataSup.Recordset!telepon = Me.txttelp.Text
Me.DataSup.Recordset.Update
'Mengaktifkan TombolMe.cmdbatal.Enabled = False
Me.cmdsimpan.Enabled = False
Me.cmdkeluar.Enabled = True
Me.cmdtambah.Enabled = True
'memanggil Prosedurtdksiapisi
bersih
End Sub
Private Sub cmdtambah_Click()
'Membuat Data BaruMe.DataSup.Recordset.AddNew
siapisi
bersih
Me.txtkode.SetFocus
'Mengaktifkan TombolMe.cmdbatal.Enabled = True
Me.cmdsimpan.Enabled = True
Me.cmdkeluar.Enabled = False
Me.cmdtambah.Enabled = False
End Sub
Private Sub csatuan_Click()Me.txtharga.SetFocus
End Sub
Private Sub cmdupdate_Click()
'Menyimpan Perubahan Data dalam databaseMe.DataSup.Recordset.Edit
Me.DataSup.Recordset!namasup = Me.txtnama.Text
Me.DataSup.Recordset!alamat = Me.txtalamat.Text
Me.DataSup.Recordset!kota = Me.txtkota.Text
Me.DataSup.Recordset!telepon = Me.txttelp.Text
Me.DataSup.Recordset.Update
tdksiapisi
bersih
'Aktif TombolMe.cmdtambah.Enabled = True
Me.cmdbrowse.Enabled = True
End Sub
Private Sub DBGrid1_Click()
'Untuk Menampikan Field DbGrid ke Form
If Me.DataSup.Recordset.RecordCount > 0 Then
Me.txtkode.Text = Me.DataSup.Recordset!kodesup
Me.txtnama.Text = Me.DataSup.Recordset!namasup
Me.txtalamat.Text = Me.DataSup.Recordset!alamat
Me.txtkota.Text = Me.DataSup.Recordset!kota
Me.txttelp.Text = Me.DataSup.Recordset!telepon
End If
tdksiapisi
Me.cmdedit.Enabled = True
Me.cmdhapus.Enabled = True
Me.cmdtambah.Enabled = False
Me.cmdbrowse.Enabled = False
End Sub
Private Sub Form_Activate()tdksiapisi
bersih
Me.cmdbatal.Enabled = False
Me.cmdsimpan.Enabled = False
Me.cmdedit.Enabled = False
Me.cmdupdate.Enabled = False
Me.cmdhapus.Enabled = False
'Mengaktifkan Index Kode Barang
Mkodesup = ""
Me.DataSup.Recordset.Index = "Kodesup"
End Sub
Private Sub txtalamat_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then
Me.txtkota.SetFocus
End If
End Sub
Private Sub txtkode_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then
Me.txtnama.SetFocus
End If
End Sub
Private Sub txtkota_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then
Me.txttelp.SetFocus
End If
End Sub
Private Sub txtnama_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then
Me.txtalamat.SetFocus
End If
End Sub
Private Sub txttelp_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then
Me.cmdsimpan.SetFocus
End If
End Sub
DOWNLOAD VERSI WORD
0 komentar:
Posting Komentar