Baca Penuh >>> <<< Kembali
Buat Table Customer :
Name Type Size Keteranga
Kodecus Text 6 PrimaryKey
Namacus Text 30
Alamat Text 35
Kota Text 15
Telp Text 15
Design Properties
Name : DataCus
Databasename : Cari Berdasarkan penyimpanan Database masing-masing
Recordset type : 1-dynaset
RecordSource : Custumer
Visible : False
Name : DBgrid1
Caption : Data Custumer
DataSource : DataCus
Name : FormCus
BorderStyle : 1-Fixed Single
Caption : Input Data Customer
Control Box : False
StartupPosition : 2 - Center Screan
Name : cmdtop
Caption : Kosongkan
Picture : c:\program file\Microsoft Visual Studio\Vft98\Graphics\top
Style : 1 - Graphics
ToolTipText : Top
Name : cmdprev
Caption : Kosongkan
Picture : c:\program file\Microsoft Visual Studio\Vft98\Graphics\top
Style : 1 - Graphics
ToolTipText : Previous
Name : cmdnext
Caption : Kosongkan
Picture : c:\program file\Microsoft Visual Studio\Vft98\Graphics\top
Style : 1 - Graphics
ToolTipText : Next
Name : cmdbottom
Caption : Kosongkan
Picture : c:\program file\Microsoft Visual Studio\Vft98\Graphics\top
Style : 1 - Graphics
ToolTipText : Last
LISTING PROGRAM
Sub tampil()
Me.txtkode.Text = Me.DataCus.Recordset!kodecus
Me.txtnama.Text = Me.DataCus.Recordset!namacus
Me.txtalamat.Text = Me.DataCus.Recordset!alamat
Me.txttelp.Text = Me.DataCus.Recordset!telp
Me.ckota.Text = Me.DataCus.Recordset!kota
End Sub
Sub siapisi()
'objek berfungsi untuk siap isi
Me.txtkode.Enabled = True
Me.txtnama.Enabled = True
Me.txtalamat.Enabled = True
Me.ckota.Enabled = True
Me.txttelp.Enabled = True
End Sub
Sub tdksiapisi()
Me.txtkode.Enabled = False
Me.txtnama.Enabled = False
Me.txtalamat.Enabled = False
Me.ckota.Enabled = False
Me.txttelp.Enabled = False
End Sub
Sub bersih()
Me.txtkode.Text = ""
Me.txtnama.Text = ""
Me.txtalamat.Text = ""
Me.ckota.Text = ""
Me.txttelp.Text = ""
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
End Sub
Private Sub Form_Load()
Me.ckota.AddItem "Jakarta"
Me.ckota.AddItem "Bandung"
Me.ckota.AddItem "Semarang"
Me.ckota.AddItem "Surabaya"
End Sub
Private Sub ckota_Click()
Me.txttelp.SetFocus
End Sub
Private Sub cmdbottom_Click()
Me.DataCus.Recordset.MoveLast
tampil
tdksiapisi
Me.cmdedit.Enabled = True
End Sub
Private Sub cmdnext_Click()
On Error Resume Next
Me.DataCus.Recordset.MoveNext
tampil
If Me.DataCus.Recordset.EOF Then
MsgBox "Sudah Akhir Record", 43, "Info"
Me.DataCus.Recordset.MoveLast
tampil
tdksiapisi
End If
Me.cmdedit.Enabled = True
End Sub
Private Sub cmdprev_Click()
On Error Resume Next
Me.DataCus.Recordset.MovePrevious
tampil
If Me.DataCus.Recordset.BOF Then
MsgBox "Sudah di awal record", 64, "Info"
Me.DataCus.Recordset.MoveFirst
tampil
tdksiapisi
End If
Me.cmdedit.Enabled = True
End Sub
Private Sub cmdtop_Click()
Me.DataCus.Recordset.MoveFirst
tampil
tdksiapisi
Me.cmdedit.Enabled = True
End Sub
Private Sub cmdtambah_Click()
'Membuat Data Baru
Me.DataCus.Recordset.AddNew
siapisi
bersih
Me.txtkode.SetFocus
'Mengaktifkan Tombol
Me.cmdbatal.Enabled = True
Me.cmdsimpan.Enabled = True
Me.cmdkeluar.Enabled = False
Me.cmdtambah.Enabled = False
End Sub
Private Sub cmdsimpan_Click()
'Menyimpan Data dalam database
Me.DataCus.Recordset.AddNew
Me.DataCus.Recordset!kodecus = Me.txtkode.Text
Me.DataCus.Recordset!namacus = Me.txtnama.Text
Me.DataCus.Recordset!alamat = Me.txtalamat.Text
Me.DataCus.Recordset!kota = Me.ckota.Text
Me.DataCus.Recordset!telp = Me.txttelp.Text
Me.DataCus.Recordset.Update
'Mengaktifkan Tombol
Me.cmdbatal.Enabled = False
Me.cmdsimpan.Enabled = False
Me.cmdkeluar.Enabled = True
Me.cmdtambah.Enabled = True
'memanggil Prosedur
tdksiapisi
bersih
End Sub
Private Sub DBGrid1_Click()
If Me.DataSup.Recordset.RecordCount > 0 Then
Me.txtkode.Text = Me.DataCus.Recordset!kodesup
Me.txtnama.Text = Me.DataCus.Recordset!namasup
Me.txtalamat.Text = Me.DataCus.Recordset!alamat
Me.ckota.Text = Me.DataCus.Recordset!kota
Me.txttelp.Text = Me.DataCus.Recordset!telp
End If
tdksiapisi
Me.cmdedit.Enabled = True
Me.cmdhapus.Enabled = True
Me.cmdtambah.Enabled = False
Me.cmdbrowse.Enabled = False
End Sub
Private Sub cmdedit_Click()
'mengaktifkan textbox
Me.txtnama.Enabled = True
Me.txtalamat.Enabled = True
Me.ckota.Enabled = True
Me.txttelp.Enabled = True
'mentidakaktifkan commbobox
Me.cmdtambah.Enabled = False
Me.cmdhapus.Enabled = False
Me.cmdedit.Enabled = False
'mengaktifkan tombol
Me.cmdupdate.Enabled = True
End Sub
Private Sub cmdupdate_Click()
'Menyimpan Perubahan Data dalam database
Me.DataCus.Recordset.Edit
Me.DataCus.Recordset!namacus = Me.txtnama.Text
Me.DataCus.Recordset!alamat = Me.txtalamat.Text
Me.DataCus.Recordset!kota = Me.ckota.Text
Me.DataCus.Recordset!telp = Me.txttelp.Text
Me.DataCus.Recordset.Update
tdksiapisi
bersih
'Aktif Tombol
Me.cmdtambah.Enabled = True
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 cmdhapus_Click()
'perintah menghapus record data
Dim A As Byte
A = MsgBox(" Betul akan dihapus ?", vbOKCancel, "mengahapus record")
If X = vbOK Then
Me.DataCus.Recordset.Delete
Me.DataCus.Recordset.MoveNext
If Me.DataCus.Recordset.EOF Then
Me.DataCus.Recordset.MoveLast
End If
End If
bersih
tdksiapisi
End Sub
Private Sub cmdkeluar_Click()
Unload Me
End Sub
Private Sub txtalamat_KeyPress(KeyAscii As Integer)
'untuk membuat huruf otomatis Caps Lock
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
Me.ckota.SetFocus
End If
End Sub
Private Sub txtkode_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
CARI = "kodecus='" & Me.txtkode.Text & "'"
Me.DataCus.Recordset.FindFirst CARI
If Me.DataCus.Recordset.NoMatch Then
Me.txtnama.SetFocus
Else
MsgBox "Kode yang anda input sudah ada", 0, "Informasi"
Me.txtkode.SetFocus
Me.txtkode.Text = ""
End If
End If
End Sub
Private Sub txtkota_KeyPress(KeyAscii As Integer)
'untuk membuat huruf otomatis Caps Lock
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
Me.txttelp.SetFocus
End If
End Sub
Private Sub txtnama_KeyPress(KeyAscii As Integer)
'untuk membuat huruf otomatis Caps Lock
KeyAscii = Asc(UCase(Chr(KeyAscii)))
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