Buat database Kursus
Buat table siswa
Name Type Size
nis * Text 8
nama Text 30
alamat Text 30
telp Text 15
jns_kel Text 15
Buat procedure bersih, mati dan hidup di Module
Sub nis()
‘membuat nis secara otomatis
With dtsiswa.RecordsetDim a As String
If .EOF Then
'jika belum ada record
TXTNIS.Text = Format(Date, "yyyy") & "001"
Else
.MoveLast
a = Val(Right(!nis, 3)) + 1
TXTNIS.Text = Format(Date, "yyyy") & Right("000" & a, 3)
End If
End With
End Sub
Private Sub Form_Load()
mati Me
bersih Me
CMDADD.Enabled = True
cmdsave.Enabled = False
CMDUNDO.Enabled = False
cmdexit.Enabled = True
End Sub
Private Sub CMDADD_Click()
hidup Me
TXTNIS.Enabled = False
bersih Me
nis 'memunculkan nis secara otomatis
cmdsave.Enabled = True
CMDUNDO.Enabled = True
CMDADD.Enabled = False
End Sub
Private Sub cmdsave_Click()
With dtsiswa.Recordset
.AddNew
!nis = TXTNIS.Text
!nama = txtnama.Text
!alamat = txtalamat.Text
!TELP = TXTTELP.Text
If Option1.Value = True Then
‘jika yang dipilih option Laki-Laki
!Jns_kel = Option1.Caption
Else
‘jika yang dipilih option Perempuan
!Jns_kel = Option2.Caption
End If
.Update
End With
Form_Load
End Sub
Private Sub CMDUNDO_Click()
Form_Load
End Sub
Private Sub cmdexit_Click()
End
End Sub