Professional Documents
Culture Documents
Text1.MaxLength = 6
Text2.MaxLength = 30
Text3.MaxLength = 13
Text4.MaxLength = 4
Text5.MaxLength = 4
Kondisiawal
End Sub
'buka database
Call BukaDB
Conn.CursorLocation = adUseClient
With RSPerpustakaan
mvBookMark = .Bookmark
End If
End With
'hubungkan datagrid ke tabel barang
End Sub
Function CariData()
Call BukaDB
RSPerpustakaan.Open "Select * From perpustakaan where KodeBuku='" & Text1 & "'", Conn
End Function
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
End Sub
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
End Sub
Private Sub TidakSiapIsi()
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
End Sub
KosongkanText
TidakSiapIsi
Cmdinput.Caption = "&Input"
Cmdedit.Caption = "&Edit"
Cmdhapus.Caption = "&Hapus"
Cmdtutup.Caption = "&Tutup"
Cmdinput.Enabled = True
Cmdedit.Enabled = True
Cmdhapus.Enabled = True
End Sub
With RSPerpustakaan
If Not RSPerpustakaan.EOF Then
Text2 = RSPerpustakaan!NamaBuku
Text3 = RSPerpustakaan!ISBN
Text4 = RSPerpustakaan!TahunTerbit
Text5 = RSPerpustakaan!JumlahBuku
End If
End With
End Sub
Cmdinput.SetFocus
Cmdedit.SetFocus
End If
Call Kondisiawal
Form Activate
End Sub
Cmdinput.Enabled = False
Cmdedit.Caption = "&Simpan"
Cmdhapus.Enabled = False
Cmdtutup.Caption = "&Batal"
SiapIsi
Text1.SetFocus
Else
Else
'edit data
SQLEdit = "Update perpustakaan Set NamaBuku= '" & Text2 & "', ISBN='" & Text3 & "',
TahunTerbit='" & Text4 & "',JumlahBuku='" & Text5 & "' where KodeBuku='" & Text1 & "'"
Conn.Execute SQLEdit
Cmdrefresh.SetFocus
End If
End If
End Sub
Cmdinput.Enabled = False
Cmdedit.Enabled = False
Cmdtutup.Caption = "&Batal"
KosongkanText
SiapIsi
Text1.SetFocus
End If
End Sub
Cmdinput.Caption = "&Simpan"
Cmdedit.Enabled = False
Cmdhapus.Enabled = False
Cmdtutup.Caption = "&Batal"
SiapIsi
KosongkanText
Text1.SetFocus
Else
If Text1 = "" Or Text2 = "" Or Text3 = "" Or Text4 = "" Or Text5 = "" Then
Else
'simpan data
Conn.Execute SQLTambah
Cmdrefresh.SetFocus
End If
End If
End Sub
Private Sub Cmdtutup_Click()
Case "&Tutup"
Unload Me
Case "&Batal"
TidakSiapIsi
Kondisiawal
End Select
End Sub
End Sub
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
Text1.SetFocus
Exit Sub
Else
Text2.SetFocus
End If
Call CariData
TampilkanData
KosongkanText
Text1.SetFocus
Else
Text2.SetFocus
End If
End If
Call CariData
TampilkanData
Text1.Enabled = False
Text2.SetFocus
Else
Text1 = ""
Text1.SetFocus
End If
End If
Call CariData
TampilkanData
SQLHapus = "Delete From perpustakaan where kodebuku= '" & Text1 & "'"
Conn.Execute SQLHapus
Kondisiawal
Cmdrefresh.SetFocus
Else
Kondisiawal
Cmdhapus.SetFocus
End If
Else
Text1.SetFocus
End If
End If
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then KeyAscii = 0
End Sub
If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then KeyAscii = 0
End Sub
If KeyAscii = 13 Then
Cmdinput.SetFocus
Cmdedit.SetFocus
End If
End If
If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then KeyAscii = 0
End Sub
CmdInput.Enabled = False
CmdEdit.Caption = "Simpan"
CmdHapus.Enabled = False
CmdTutup.Caption = "Batal"
SiapIsi
nip.SetFocus
Else
If nama = "" Or kd_jabat = "" Or kd_gol = "" Or status = "" Or jml_anak = "" Then
Else
'edit data
SQLEdit = "Update Pegawai Set Nama= '" & nama & "', Kd_Jabat='" & kd_jabat & "', Kd_Gol='" &
kd_gol & "',Status='" & status & "',Jml_Anak='" & jml_anak & "' where nip='" & nip & "'"
Conn.Execute SQLEdit
CmdRef.SetFocus
End If