Anda di halaman 1dari 6

VISUAL BASIC 6.

0 MEMBUAT FORM TRANSAKSI PENDAFTARAN MAHASISWA BARU


ASEP JALALUDIN,S.T.,M.M. Halaman - 1


Membuat koneksi Database di Adodc menggunakan Jet DB OLE 4.0 :


VISUAL BASIC 6.0 MEMBUAT FORM TRANSAKSI PENDAFTARAN MAHASISWA BARU
ASEP JALALUDIN,S.T.,M.M. Halaman - 2
Membuat koneksi Table di RecordSource di Adodc Properties :


Menampilkan field-field di Grid :


Coding-nya sbb :

Dim conn As New ADODB.Connection
Dim RSmaba As ADODB.Recordset
Dim RSfo As ADODB.Recordset
Dim Rsdaftar As ADODB.Recordset
Dim mvBookMark As Variant
VISUAL BASIC 6.0 MEMBUAT FORM TRANSAKSI PENDAFTARAN MAHASISWA BARU
ASEP JALALUDIN,S.T.,M.M. Halaman - 3
Sub BukaDB()
Set conn = New ADODB.Connection
Set RSmaba = New ADODB.Recordset
Set RSfo = New ADODB.Recordset
Set Rsdaftar = New ADODB.Recordset
conn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\pendaftaran.mdb"
End Sub
Private Sub Combo2_Click()
Call BukaDB
Call CariData
Call tampilkandata
End Sub

Private Sub Command2_Click(Index As Integer)
Adodc1.Recordset.Delete
Text1.Text = ""
DTPicker1.Value = Date
Text3.Text = ""
Text4.Text = ""
Text5.Text = 0
Combo1.Text = ""
Text6.Text = ""
Combo2.Text = ""
Text7.Text = ""
MsgBox "Data sudah dihapus"
Adodc1.Refresh
End Sub

Private Sub Command3_Click(Index As Integer)
Adodc1.Recordset!no_kwit = Text1.Text
Adodc1.Recordset!tgl_daftar = DTPicker1.Value
Adodc1.Recordset!jenis_bayar = Text3.Text
Adodc1.Recordset!ket = Text4.Value
Adodc1.Recordset!jumlah = Text5.Value
Adodc1.Recordset!no_peserta = Combo1.Text
Adodc1.Recordset!nama_maba = Text6.Text
Adodc1.Recordset!nip = Combo2.Text
Adodc1.Recordset!nama_peg = Text7.Text
Adodc1.Recordset.Update
MsgBox "Data sudah diubah"
End Sub

Private Sub DataGrid1_Click()
Text1.Text = Adodc1.Recordset!no_kwit
DTPicker1.Value = Adodc1.Recordset!tgl_daftar
Text3.Text = Adodc1.Recordset!jenis_bayar
Text4.Text = Adodc1.Recordset!ket
Text5.Text = Adodc1.Recordset!jumlah
VISUAL BASIC 6.0 MEMBUAT FORM TRANSAKSI PENDAFTARAN MAHASISWA BARU
ASEP JALALUDIN,S.T.,M.M. Halaman - 4
Combo1.Text = Adodc1.Recordset!no_peserta
Text6.Text = Adodc1.Recordset!nama_maba
Combo2.Text = Adodc1.Recordset!nip
Text7.Text = Adodc1.Recordset!nama_peg
End Sub

Private Sub Form_Activate()
Call BukaDB
conn.CursorLocation = adUseClient
RSmaba.Open "select * from maba", conn
With RSmaba
If Not (.BOF And .EOF) Then
mvBookMark = .Bookmark
End If
End With

Call BukaDB
conn.CursorLocation = adUseClient
RSfo.Open "select * from fo", conn
With RSfo
If Not (.BOF And .EOF) Then
mvBookMark = .Bookmark
End If
End With

Set DataGrid1.DataSource = RSmaba.DataSource
Set DataGrid1.DataSource = RSfo.DataSource

Call BukaDB
RSmaba.Open "maba", conn
Combo1.Clear
Do Until RSmaba.EOF
Combo1.AddItem RSmaba!no_peserta
RSmaba.MoveNext
Loop

Call BukaDB
RSfo.Open "fo", conn
Combo2.Clear
Do Until RSfo.EOF
Combo2.AddItem RSfo!nip
RSfo.MoveNext
Loop
End Sub
Function CariData()
Call BukaDB
RSmaba.Open "Select * From maba where no_peserta='" & Text6 & "'", conn
Call BukaDB
RSfo.Open "Select * From fo where nip='" & Text7 & "'", conn
VISUAL BASIC 6.0 MEMBUAT FORM TRANSAKSI PENDAFTARAN MAHASISWA BARU
ASEP JALALUDIN,S.T.,M.M. Halaman - 5
End Function
Private Sub tampilkandata()
Call BukaDB
RSmaba.Open "Select * From maba where no_peserta = '" & Combo1 & "'", conn
If Not RSmaba.EOF Then
Text6 = RSmaba!nama_maba
End If

Call BukaDB
RSfo.Open "Select * From fo where nip = '" & Combo2 & "'", conn
If Not RSfo.EOF Then
Text7 = RSfo!nama_peg
End If
End Sub
Private Sub Combo1_Click()
Call BukaDB
Call CariData
Call tampilkandata
End Sub
Private Sub Command5_Click(Index As Integer)
Unload Me
End Sub
Private Sub Form_Load()
Text6.Enabled = False
Text7.Enabled = False

End Sub

Private Sub simpan_Click(Index As Integer)
Set Rsdaftar = New ADODB.Recordset
Adodc1.Recordset.Fields("no_kwit") = Text1.Text
Adodc1.Recordset.Fields("tgl_daftar") = DTPicker1.Value
Adodc1.Recordset.Fields("jenis_bayar") = Text3.Text
Adodc1.Recordset.Fields("ket") = Text4.Text
Adodc1.Recordset.Fields("jumlah") = Text5.Text
Adodc1.Recordset.Fields("no_peserta") = Combo1.Text
Adodc1.Recordset.Fields("nama_maba") = Text6.Text
Adodc1.Recordset.Fields("nip") = Combo2.Text
Adodc1.Recordset.Fields("nama_peg") = Text7.Text

MsgBox "Data sudah disimpan"
Set DataGrid1.DataSource = Rsdaftar
'DataGrid1.Refresh

Text1.Text = ""
DTPicker1.Value = Date
Text3.Text = ""
Text4.Text = ""
Text5.Text = 0
VISUAL BASIC 6.0 MEMBUAT FORM TRANSAKSI PENDAFTARAN MAHASISWA BARU
ASEP JALALUDIN,S.T.,M.M. Halaman - 6
Combo1.Text = ""
Text6.Text = ""
Combo2.Text = ""
Text7.Text = ""

End Sub
Private Sub tambah_Click()
Text1.SetFocus
Adodc1.Recordset.AddNew
pesan = MsgBox("Anda mau menambah data?", vbInformation, "Informasi")

Set Rsdaftar = New ADODB.Recordset

Text1.Text = ""
DTPicker1.Value = Date
Text3.Text = ""
Text4.Text = ""
Text5.Text = 0
Combo1.Text = ""
Text6.Text = ""
Combo2.Text = ""
Text7.Text = ""

Adodc1.Recordset!no_kwit = ""
'Adodc1.Recordset!tgl_daftar = ""
Adodc1.Recordset!jenis_bayar = ""
Adodc1.Recordset!ket = ""
Adodc1.Recordset!jumlah = 0
Adodc1.Recordset!no_peserta = ""
Adodc1.Recordset!nama_maba = ""
Adodc1.Recordset!nip = ""
Adodc1.Recordset!nama_peg = ""

End Sub



Selamat Mengerjakan
~asj~