listing program frmanggota
DESCRIPTION
listing program untuk anggotaTRANSCRIPT
Listing Program
frmAnggota.frm
Private Sub cmdEdit_Click()
blnEdit = True
Fokus Text(1)
cmdEdit.Enabled = False
cmdHapus.Enabled = False
End Sub
Private Sub cmdHapus_Click()
On Error GoTo ErrDelete
cnBPR.Execute "Delete * from tblAnggota Where NoAnggota='" & Text(0).Text & "'"
Semula
Exit Sub
ErrDelete:
MsgBox Err.Description & Err.Number
End Sub
Private Sub cmdSimpan_Click()
For i = 0 To 2
If Text(i).Text = "" Then
MsgBox " Data Anggota Belum Lengkap", vbCritical
Fokus Text(i)
Exit Sub
End If
Next
Me.MousePointer = 11
If Not blnEdit Then
SimpanData
Else
EditData
End If
Semula
Me.MousePointer = 1
End Sub
Private Sub cmdTambah_Click()
If cmdTambah.Caption = "&Tambah" Then
cmdTambah.Caption = "&Batal"
Fokus Text(0)
Else
Semula
End If
End Sub
Private Sub cmdTutup_Click()
Unload Me
End Sub
Private Sub Form_Load()
Ketengah Me
End Sub
Sub Semula()
cmdTambah.Caption = "&Tambah"
cmdTambah.SetFocus
cmdSimpan.Enabled = False
cmdEdit.Enabled = False
cmdHapus.Enabled = False
blnEdit = False
ClearControl Me
End Sub
Sub Daftar()
With oBPR
Text(1) = !Nama
Text(2) = !Alamat
Text(3) = !Kota
Text(4) = !NoTelp
Text(5) = !Pekerjaan
End With
End Sub
Private Sub Text_KeyPress(Index As Integer, KeyAscii As Integer)
Select Case Index
Case 0
If KeyAscii = 13 Then
cmdSimpan.Enabled = True
Query "Select * from tblAnggota Where NoAnggota='" & Text(0).Text & "'"
If oBPR.EOF Then
oBPR.Close
Set oBPR = Nothing
Fokus Text(1)
cmdSimpan.Enabled = True
Exit Sub
End If
Daftar
oBPR.Close
Set oBPR = Nothing
cmdEdit.Enabled = True
cmdHapus.Enabled = True
End If
Case 1 To 4
If KeyAscii = 13 Then
SendKeys "{Tab}"
End If
Case 5
If KeyAscii = 13 Then
cmdSimpan.Enabled = True
cmdSimpan.SetFocus
End If
End Select
End Sub
Sub SimpanData()
On Error GoTo ErrSimpan
If Not cnBPR Is Nothing Then
If cnBPR.State > 0 Then
cnBPR.Execute "Insert Into tbLAnggota Values ('" & Text(0).Text & "'," & _
"'" & Text(1).Text & "'," & _
"'" & Text(2).Text & "'," & _
"'" & Text(3).Text & "'," & _
"'" & Text(4).Text & "'," & _
"'" & Text(5).Text & "')"
End If
End If
Exit Sub
ErrSimpan:
MsgBox " System Tidak Dapat melakukan penyimpanan datat...", vbCritical
End Sub
Sub EditData()
On Error GoTo ErrEdit
If Not cnBPR Is Nothing Then
If cnBPR.State > 0 Then
cnBPR.Execute "Update tblAnggota Set Nama='" & Text(1).Text & "',Alamat='" & _
Text(2).Text & "',Kota='" & Text(3).Text & "',NoTelp='" & Text(4).Text & "',Pekerjaan='" & _
Text(5).Text & "' Where NoAnggota='" & Text(0).Text & "'"
End If
End If
Exit Sub
ErrEdit:
MsgBox " System Tidak dapat melakukan Edit data Anggota...", vbCritical
End Sub