MEMBUAT SISTEM PENJUALAN
Buatlah Database penjualan.mdb simpanlah pada
drive C:/, dan buatlah Tabel pertama dengan nama Tabel Pelanggan, isilah table
tersebut dengan property sebagai berikut :
Field
|
Size
|
Property
|
kodeplgn
|
10
|
Number
|
nmplgn
|
30
|
Text
|
alamat
|
50
|
Text
|
tlp
|
12
|
Number
|
1.
Buatlah form 1 dengan caption Tabel Pelanggan,
seperti berikut :
2.
Klik Project à Refernces … setting seperti di
bawah ini
3.
Double Klik pada command Buton Simpan, ketik
kode berikut :
Public kon As New
ADODB.Connection
Public rs1 As New
ADODB.Recordset
Private Sub
Command1_Click()
If Text1 = "" Or
Text2 = "" Or Text3 = "" Or Text4 = "" Then
MsgBox "Data Belum
Lengkap...!", vbInformation, "Informasi"
Else
Dim SQLTambah As String
SQLTambah = "insert
into pelanggan (kodeplgn,nmplgn,alamat, tlp) values ('" _
& Text1 &
"','" & Text2 & "','" & Text3 &
"','" & Text4 & "')"
kon.Execute SQLTambah
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
End If
End Sub
Private Sub
Command2_Click()
End
End Sub
Private Sub
Form_Activate()
Set kon = New
ADODB.Connection
Set rs1 = New
ADODB.Recordset
kon.Open
"provider=Microsoft.jet.oledb.4.0;data source=" & App.Path &
"\penjualan.mdb"
End Sub
Private Sub
Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If Text1 <> "" And KeyCode
= 13 Then
Text2.SetFocus
End If
End Sub
Private Sub
Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If Text2 <> "" And KeyCode
= 13 Then
Text3.SetFocus
End If
End Sub
Private Sub
Text3_KeyDown(KeyCode As Integer, Shift As Integer)
If Text3 <> "" And KeyCode
= 13 Then
Text4.SetFocus
End If
End Sub
5.
Simpan dan jalankan