Coding Cari Jenis Barang

Dim RsTempAFI As New ADODB.Recordset
Public kodex, namax As String

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'saat ditekan tombol esc maka akan keluar dari form
If KeyCode = vbKeyEscape Then Unload Me
End Sub


Private Sub Form_Load()
'saat form diload mengisikan data jenis barang -> grid yang aktif
refreshData ""
End Sub

Sub refreshData(cari As String)
'prosedur meminta data jenis barang ke db
Set Grid.DataSource = Nothing

'sql query
SQL = "select Kodejenis as 'Kode Jenis',namaJenis as 'Nama Jenis' from jenisBarang " & _
        " where aktif='Y' and  namajenis like '%" & Trim(cari) & "%' order by namajenis "
Grid.Refresh

'isi data jenis barang db -> rstempAFI
Set RsTempAFI = DbCon.Execute(SQL)

'isi data jenis barang rstempAFI -> Grid
Set Grid.DataSource = RsTempAFI

End Sub

Private Sub Grid_DblClick()
'saat grid ditekan 2x
'kodex diisi colum 1
kodex = Trim(Grid.Columns(0).Text)
'namax diisi colum 2
namax = Trim(Grid.Columns(1).Text)
'tutup form
Unload Me
End Sub

Private Sub Grid_KeyDown(KeyCode As Integer, Shift As Integer)
'saat grid ditekan enter
If KeyCode = 13 Then
    'kodex diisi colum 1
    kodex = Trim(Grid.Columns(0).Text)
    'namax diisi colum 2
    namax = Trim(Grid.Columns(1).Text)
    'tutup form
    Unload Me
End If
End Sub

Private Sub TxtCari_Change()
'saat text cari diisi
refreshData Trim(TxtCari)
End Sub
Private Sub TxtCari_KeyPress(KeyAscii As MSForms.ReturnInteger)
'ubah isian ditext cari menjadi huruf besar
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub


Comments

Popular posts from this blog

Flowchart Penjualan Grosir / Eceran

Flowchart Proses Pembelian Barang