1. Buat database dari Ms.Access. Start > All Programs > Microsoft Office >Microsoft Office Access 2007
2. Klik Blank Database, lalu browse dan simpan dengan nama db_biodata, rubah file ekstensinya (Save As Type) menjadi file access (2003), setelah selesai klik Save lalu klik Create.
3. Lalu buat table, klik kanan pada table seperti yang di gambar di bawah ini, lalu pilih Design View. dan beri nama db_biodata pada table
4. Dan isikan field-fieldnya
Field Name | Data Type | Field Size | Format |
Nama | Text | 25 | |
Kota_Lahir | Text | 10 | |
Tgl_Lahir | Date/Time | Short Date | |
Agama | Text | 10 | |
No_Tlp | Text | 13 | |
Alamat | Memo | ||
Kategori | Text | 10 | |
Foto | Memo |
5. Lalu buka Visual Basic 6.0, Start > All Programs > Microsoft Viual Basic 6.0 >
Microsoft Viual Basic 6.0
6. Lalu pilih Standart EXE dan klik Open.
7. Klik kanan pada Toolbar Component, lalu pilih Component.. (ini untuk menambah kan komponen yang di butuhkan nanti)
8. Centangkan Microsoft ADO Data Control 6.0 (OLEDB), Microsoft Common Dialog Control 6.0, Microsoft DataGrid Control 6.0 (OLEDB), Microsoft Windows Common Control-2 6.0, klik Ok
9. Buatlah tampilan seperti gambar di bawah ini
Komponen | Caption |
Command1 | Buka Foto |
Command2 | Simpan |
Command3 | Hapus |
Command4 | Preview |
Command5 | Edit |
Frame1 | Input Biodata |
Frame2 | View Biodata |
Label1 | Nama |
Label2 | Kota Lahir |
Label3 | Tanggal Lahir |
Label4 | Agama |
Label5 | Nomer Telepon |
Label6 | Alamat |
Label7 | Kategori |
Label8 | Foto |
Komponen/Letak | Text |
Text1/Nama | "" |
Text2/Kota Lahir | "" |
Text3/No Tlp | "" |
Text4/Alamat | "" |
Combo1 | "" |
Combo2 | "" |
Komponen |
DTPicker1 |
CommonDialog1 |
DataGrid1 |
Adodc1 |
10. Berikut cara mengkoneksikan vb6 dengan Ms.Accessklik kanan pada Adodc pilih ADODC Properties, akan muncul seperti gambar di bawah ini. lalu pilih Use Connection String, lalu klik Build
11. Pilih Microsoft Jet 4.0 OLE DB Provider, lalu klik Next
12. Browse file, masukan database yang tadi sudah di buat sebelumnya, lalu klik Test Connection, Jika Berhasil akan muncul Pesan di bawah ini, jika terjadi error, periksa kembali databasenya
13. Setelah itu Pilih RecordSource. ubah Command Type menjadi 2-adCmdTable, dan bagian Table of Stored Procedure Name, ubah menjadi table yang sudah di buat sebelumnya.
14. Ubah DataSource pada DataGrid menjadi Adodc1
15. yang terakhir ubah pada text Alamat, multiline text menjadi true, dan ubah ScrolBars menjadi vertical
Dim save As Integer
Private Sub Command1_Click()
On Error GoTo err
CommonDialog1.ShowOpen
Image1.Picture = LoadPicture(CommonDialog1.FileName)
err:
End Sub
Private Sub Command2_Click()
If Command2.Caption = "Simpan" Then
a = Trim(Text1.Text)
b = Trim(Text2.Text)
c = Trim(Text3.Text)
d = Trim(Text4.Text)
e = Trim(Combo1.Text)
f = Trim(Combo2.Text)
g = Trim(DTPicker1.Value)
h = CommonDialog1.FileName
If a = "" Or b = "" Or c = "" Or d = "" Or _
e = "" Or f = "" Or g = "" Or h = "" Then
MsgBox "Maaf Data Belum Lengkap", vbCritical, "Created By Ganang"
Exit Sub
End If
If save = 0 Then
Adodc1.Recordset.AddNew
Else
save = 0
End If
Adodc1.Recordset.Fields("Nama") = a
Adodc1.Recordset.Fields("Kota_Lahir") = b
Adodc1.Recordset.Fields("Tgl_Lahir") = g
Adodc1.Recordset.Fields("Agama") = e
Adodc1.Recordset.Fields("No_Tlp") = c
Adodc1.Recordset.Fields("Alamat") = d
Adodc1.Recordset.Fields("Kategori") = f
Adodc1.Recordset.Fields("Foto") = h
DataGrid1.Refresh
Command3.Enabled = True
Command4.Enabled = True
DataGrid1.Enabled = True
MsgBox "Data Berhasil Di Input", vbInformation, "Created By Ganang"
Else
Command2.Caption = "Simpan"
Command5.Enabled = True
Command3.Enabled = True
End If
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Combo1.Text = "-- Pilih Agama --"
Combo2.Text = "-- Pilih Kategori --"
CommonDialog1.FileName = ""
Image1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub
Private Sub Command3_Click()
If MsgBox("Apakah Ingin Di Hapus", vbYesNo + vbInformation, "Created By Ganang") = vbYes Then
Adodc1.Recordset.Delete
MsgBox "Data Berhasil Di Hapus", vbInformation, "Created By Ganang"
End If
End Sub
Private Sub Command4_Click()
Text1.Text = Adodc1.Recordset.Fields("Nama")
Text2.Text = Adodc1.Recordset.Fields("Kota_Lahir")
DTPicker1.Value = Adodc1.Recordset.Fields("Tgl_Lahir")
Combo1.Text = Adodc1.Recordset.Fields("Agama")
Text3.Text = Adodc1.Recordset.Fields("No_Tlp")
Text4.Text = Adodc1.Recordset.Fields("Alamat")
Combo2.Text = Adodc1.Recordset.Fields("Kategori")
CommonDialog1.FileName = Adodc1.Recordset.Fields("Foto")
Image1.Picture = LoadPicture(CommonDialog1.FileName)
Command2.Caption = "Close Preview"
Command3.Enabled = False
Command5.Enabled = False
End Sub
Private Sub Command5_Click()
On Error GoTo err
Text1.Text = Adodc1.Recordset.Fields("Nama")
Text2.Text = Adodc1.Recordset.Fields("Kota_Lahir")
DTPicker1.Value = Adodc1.Recordset.Fields("Tgl_Lahir")
Combo1.Text = Adodc1.Recordset.Fields("Agama")
Text3.Text = Adodc1.Recordset.Fields("No_Tlp")
Text4.Text = Adodc1.Recordset.Fields("Alamat")
Combo2.Text = Adodc1.Recordset.Fields("Kategori")
CommonDialog1.FileName = Adodc1.Recordset.Fields("Foto")
Image1.Picture = LoadPicture(CommonDialog1.FileName)
DataGrid1.Enabled = False
Command4.Enabled = False
Command3.Enabled = False
save = 1
Exit Sub
err:
MsgBox "Error Data Belum Ada", vbCritical, "Created By Ganang"
End Sub
Private Sub Form_Load()
save = 0
With Combo1
.Text = "-- Pilih Agama --"
.AddItem "Islam"
.AddItem "Kristen"
.AddItem "Hindu"
.AddItem "Budha"
End With
With Combo2
.Text = "-- Pilih Kategori --"
.AddItem "SD"
.AddItem "SMP"
.AddItem "SMA"
.AddItem "SMK"
.AddItem "Mahasiswa"
End With
DataGrid1.AllowUpdate = False
With CommonDialog1
.Filter = "*.Jpg|*.jpg|*.Bmp|*.Bmp|"
.CancelError = True
End With
With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_biodata.mdb;Persist Security Info=False"
.CommandType = adCmdTable
.RecordSource = db_biodata
End With
Image1.Stretch = True
End Sub
Private Sub Command1_Click()
On Error GoTo err
CommonDialog1.ShowOpen
Image1.Picture = LoadPicture(CommonDialog1.FileName)
err:
End Sub
Private Sub Command2_Click()
If Command2.Caption = "Simpan" Then
a = Trim(Text1.Text)
b = Trim(Text2.Text)
c = Trim(Text3.Text)
d = Trim(Text4.Text)
e = Trim(Combo1.Text)
f = Trim(Combo2.Text)
g = Trim(DTPicker1.Value)
h = CommonDialog1.FileName
If a = "" Or b = "" Or c = "" Or d = "" Or _
e = "" Or f = "" Or g = "" Or h = "" Then
MsgBox "Maaf Data Belum Lengkap", vbCritical, "Created By Ganang"
Exit Sub
End If
If save = 0 Then
Adodc1.Recordset.AddNew
Else
save = 0
End If
Adodc1.Recordset.Fields("Nama") = a
Adodc1.Recordset.Fields("Kota_Lahir") = b
Adodc1.Recordset.Fields("Tgl_Lahir") = g
Adodc1.Recordset.Fields("Agama") = e
Adodc1.Recordset.Fields("No_Tlp") = c
Adodc1.Recordset.Fields("Alamat") = d
Adodc1.Recordset.Fields("Kategori") = f
Adodc1.Recordset.Fields("Foto") = h
DataGrid1.Refresh
Command3.Enabled = True
Command4.Enabled = True
DataGrid1.Enabled = True
MsgBox "Data Berhasil Di Input", vbInformation, "Created By Ganang"
Else
Command2.Caption = "Simpan"
Command5.Enabled = True
Command3.Enabled = True
End If
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Combo1.Text = "-- Pilih Agama --"
Combo2.Text = "-- Pilih Kategori --"
CommonDialog1.FileName = ""
Image1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub
Private Sub Command3_Click()
If MsgBox("Apakah Ingin Di Hapus", vbYesNo + vbInformation, "Created By Ganang") = vbYes Then
Adodc1.Recordset.Delete
MsgBox "Data Berhasil Di Hapus", vbInformation, "Created By Ganang"
End If
End Sub
Private Sub Command4_Click()
Text1.Text = Adodc1.Recordset.Fields("Nama")
Text2.Text = Adodc1.Recordset.Fields("Kota_Lahir")
DTPicker1.Value = Adodc1.Recordset.Fields("Tgl_Lahir")
Combo1.Text = Adodc1.Recordset.Fields("Agama")
Text3.Text = Adodc1.Recordset.Fields("No_Tlp")
Text4.Text = Adodc1.Recordset.Fields("Alamat")
Combo2.Text = Adodc1.Recordset.Fields("Kategori")
CommonDialog1.FileName = Adodc1.Recordset.Fields("Foto")
Image1.Picture = LoadPicture(CommonDialog1.FileName)
Command2.Caption = "Close Preview"
Command3.Enabled = False
Command5.Enabled = False
End Sub
Private Sub Command5_Click()
On Error GoTo err
Text1.Text = Adodc1.Recordset.Fields("Nama")
Text2.Text = Adodc1.Recordset.Fields("Kota_Lahir")
DTPicker1.Value = Adodc1.Recordset.Fields("Tgl_Lahir")
Combo1.Text = Adodc1.Recordset.Fields("Agama")
Text3.Text = Adodc1.Recordset.Fields("No_Tlp")
Text4.Text = Adodc1.Recordset.Fields("Alamat")
Combo2.Text = Adodc1.Recordset.Fields("Kategori")
CommonDialog1.FileName = Adodc1.Recordset.Fields("Foto")
Image1.Picture = LoadPicture(CommonDialog1.FileName)
DataGrid1.Enabled = False
Command4.Enabled = False
Command3.Enabled = False
save = 1
Exit Sub
err:
MsgBox "Error Data Belum Ada", vbCritical, "Created By Ganang"
End Sub
Private Sub Form_Load()
save = 0
With Combo1
.Text = "-- Pilih Agama --"
.AddItem "Islam"
.AddItem "Kristen"
.AddItem "Hindu"
.AddItem "Budha"
End With
With Combo2
.Text = "-- Pilih Kategori --"
.AddItem "SD"
.AddItem "SMP"
.AddItem "SMA"
.AddItem "SMK"
.AddItem "Mahasiswa"
End With
DataGrid1.AllowUpdate = False
With CommonDialog1
.Filter = "*.Jpg|*.jpg|*.Bmp|*.Bmp|"
.CancelError = True
End With
With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_biodata.mdb;Persist Security Info=False"
.CommandType = adCmdTable
.RecordSource = db_biodata
End With
Image1.Stretch = True
End Sub
moga bermanfaat bagi agan-agan yang ingin mencobanya,
moga berhasil mencobanya..
download http://ouo.io/Uxv7tq
password rar : ganyang-angkara.blogspot.com
*..sesama blogger harus saling menghargai, jika agan-agan ingin mengcopas harap cantumkan alamat urlnya, Terimakasih..*