TAbel Relasi
Design Tampilan
1. Menu
2. Master Barang
3. MAster Customer
4. a. Form Barang Masuk
4.b. Form Detail BArang MAsuk
Coding :
1. Menu
2. MAster BArang
Private Sub cmdbatal_Click()
adobarang.Recordset.CancelBatch
End Sub
Private Sub cmdhapus_Click()
If MsgBox("Apakah Barang dengan nama " + txtidcust + " akan di hapus ?", vbQuestion + vbYesNo) = vbYes Then
adobarang.Recordset.Delete
End If
End Sub
Private Sub cmdKeluar_Click()
Unload Me
End Sub
Private Sub cmdsimpan_Click()
adobarang.Recordset.Save
End Sub
Private Sub cmdtambah_Click()
adobarang.Recordset.AddNew
txtkdbrg.SetFocus
End Sub
3. MAster Customer
Private Sub cmdbatal_Click()
adocustomer.Recordset.CancelBatch
End Sub
Private Sub cmdhapus_Click()
If MsgBox("Apakah Customer dengan nama " + txtidcust + " akan di hapus ?", vbQuestion + vbYesNo) = vbYes Then
adocustomer.Recordset.Delete
End If
End Sub
Private Sub cmdKeluar_Click()
Unload Me
End Sub
Private Sub cmdsimpan_Click()
adocustomer.Recordset.Save
End Sub
Private Sub cmdtambah_Click()
adocustomer.Recordset.AddNew
txtidcust.SetFocus
End Sub
4.a. Form BArang MAsuk
Private Sub cmdinputbaru_Click()
bersihinput
txtnomsk.SetFocus
End Sub
Private Sub cmdKeluar_Click()
Unload Me
End Sub
Private Sub cmdtmbdetail_Click()
Adobrgmsk.Recordset.AddNew
Adobrgmsk.Recordset("no_masuk") = txtnomsk.Text
Adobrgmsk.Recordset("tglmsk") = txttglmsk.Text
Adobrgmsk.Recordset("id_user") = txtkduser.Text
Adobrgmsk.Recordset.Update
Dim frm As Frmdetailbrgmasuk
Set frm = New Frmdetailbrgmasuk
Set frm.Adobrgmsk.Recordset = Adobrgmsk.Recordset.Clone
frm.txtnomsk.Text = txtnomsk.Text
frm.Show vbModal
Adodetbrgmsk.Recordset.Requery
Adobrgmsk.Recordset.Requery
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If (Not Adobrgmsk.Recordset.BOF And Not Adobrgmsk.Recordset.EOF) Then
filterdetbrgmsk Adobrgmsk.Recordset("no_masuk")
End If
End Sub
Private Sub filterdetbrgmsk(no As String)
Adodetbrgmsk.Recordset.Filter = "no_masuk='" & no & "'"
End Sub
Private Sub Form_Load()
bersihinput
End Sub
Private Sub txtnomsk_LostFocus()
Adobrgmsk.Recordset.MoveFirst
Adobrgmsk.Recordset.Find "no_masuk='" & txtnomsk.Text & "'"
If (Not Adobrgmsk.Recordset.BOF And Not Adobrgmsk.Recordset.EOF) Then
MsgBox "no masuk sudah ada"
txtnomsk.Text = ""
txtnomsk.SetFocus
End If
End Sub
Private Sub bersihinput()
txtnomsk.Text = ""
txtkduser.Text = ""
txtnmuser.Text = ""
txttglmsk.Text = ""
End Sub
Private Sub txtkduser_LostFocus()
adouser.Recordset.MoveFirst
adouser.Recordset.Find "id_user= '" & txtkduser.Text & "'"
If (adouser.Recordset.BOF Or adouser.Recordset.EOF) Then
MsgBox "Id User Tidak ditemukan"
txtkduser.Text = ""
txtkduser.SetFocus
Else
txtnmuser.Text = adouser.Recordset("nm_user")
End If
End Sub
4.b. Detail BArang MAsuk
Option Explicit
Public kodeuser As String
Private Sub bersih()
txtkdbrg.Text = ""
txtnmbrg = ""
txtjumlah = "0"
End Sub
Private Sub cmdbatal_Click()
bersih
End Sub
Private Sub cmdhapus_Click()
Adodetbrgmsk.Recordset.Delete
bersih
End Sub
Private Sub cmdOK_Click()
Adobrgmsk.Recordset.Find "no_masuk = '" & txtnomsk.Text & "'"
Adobrgmsk.Recordset.Update
Unload Me
End Sub
Private Sub cmdtambah_Click()
Adodetbrgmsk.Recordset.AddNew
Adodetbrgmsk.Recordset("no_masuk") = txtnomsk.Text
Adodetbrgmsk.Recordset("kdbrg") = txtkdbrg.Text
Adodetbrgmsk.Recordset("jmlmsk") = txtjumlah.Text
Adodetbrgmsk.Recordset.Update
Adodetbrgmsk.Recordset.Requery
Adodetbrgmsk.Recordset.Filter = "no_masuk='" & txtnomsk.Text & "'"
bersih
adobarang.Recordset.MoveFirst
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If (Not Adodetbrgmsk.Recordset.BOF And Not Adodetbrgmsk.Recordset.EOF) Then
gridtext
End If
End Sub
Private Sub Form_Load()
bersih
End Sub
Private Sub gridtext()
txtkdbrg.Text = Adodetbrgmsk.Recordset("kdbrg")
txtjumlah.Text = Adodetbrgmsk.Recordset("jmlmsk")
End Sub
Private Sub txtkdbrg_LostFocus()
adobarang.Recordset.MoveFirst
adobarang.Recordset.Find "kdbrg='" & txtkdbrg.Text & "'"
If (adobarang.Recordset.BOF Or adobarang.Recordset.EOF) Then
MsgBox "Kode Barang tidak ditemukan"
txtkdbrg.Text = ""
txtkdbrg.SetFocus
Else
txtnmbrg.Text = adobarang.Recordset("nmbrg")
End If
End Sub
Design Tampilan
1. Menu
2. Master Barang
3. MAster Customer
4. a. Form Barang Masuk
4.b. Form Detail BArang MAsuk
Coding :
1. Menu
2. MAster BArang
Private Sub cmdbatal_Click()
adobarang.Recordset.CancelBatch
End Sub
Private Sub cmdhapus_Click()
If MsgBox("Apakah Barang dengan nama " + txtidcust + " akan di hapus ?", vbQuestion + vbYesNo) = vbYes Then
adobarang.Recordset.Delete
End If
End Sub
Private Sub cmdKeluar_Click()
Unload Me
End Sub
Private Sub cmdsimpan_Click()
adobarang.Recordset.Save
End Sub
Private Sub cmdtambah_Click()
adobarang.Recordset.AddNew
txtkdbrg.SetFocus
End Sub
3. MAster Customer
Private Sub cmdbatal_Click()
adocustomer.Recordset.CancelBatch
End Sub
Private Sub cmdhapus_Click()
If MsgBox("Apakah Customer dengan nama " + txtidcust + " akan di hapus ?", vbQuestion + vbYesNo) = vbYes Then
adocustomer.Recordset.Delete
End If
End Sub
Private Sub cmdKeluar_Click()
Unload Me
End Sub
Private Sub cmdsimpan_Click()
adocustomer.Recordset.Save
End Sub
Private Sub cmdtambah_Click()
adocustomer.Recordset.AddNew
txtidcust.SetFocus
End Sub
4.a. Form BArang MAsuk
Private Sub cmdinputbaru_Click()
bersihinput
txtnomsk.SetFocus
End Sub
Private Sub cmdKeluar_Click()
Unload Me
End Sub
Private Sub cmdtmbdetail_Click()
Adobrgmsk.Recordset.AddNew
Adobrgmsk.Recordset("no_masuk") = txtnomsk.Text
Adobrgmsk.Recordset("tglmsk") = txttglmsk.Text
Adobrgmsk.Recordset("id_user") = txtkduser.Text
Adobrgmsk.Recordset.Update
Dim frm As Frmdetailbrgmasuk
Set frm = New Frmdetailbrgmasuk
Set frm.Adobrgmsk.Recordset = Adobrgmsk.Recordset.Clone
frm.txtnomsk.Text = txtnomsk.Text
frm.Show vbModal
Adodetbrgmsk.Recordset.Requery
Adobrgmsk.Recordset.Requery
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If (Not Adobrgmsk.Recordset.BOF And Not Adobrgmsk.Recordset.EOF) Then
filterdetbrgmsk Adobrgmsk.Recordset("no_masuk")
End If
End Sub
Private Sub filterdetbrgmsk(no As String)
Adodetbrgmsk.Recordset.Filter = "no_masuk='" & no & "'"
End Sub
Private Sub Form_Load()
bersihinput
End Sub
Private Sub txtnomsk_LostFocus()
Adobrgmsk.Recordset.MoveFirst
Adobrgmsk.Recordset.Find "no_masuk='" & txtnomsk.Text & "'"
If (Not Adobrgmsk.Recordset.BOF And Not Adobrgmsk.Recordset.EOF) Then
MsgBox "no masuk sudah ada"
txtnomsk.Text = ""
txtnomsk.SetFocus
End If
End Sub
Private Sub bersihinput()
txtnomsk.Text = ""
txtkduser.Text = ""
txtnmuser.Text = ""
txttglmsk.Text = ""
End Sub
Private Sub txtkduser_LostFocus()
adouser.Recordset.MoveFirst
adouser.Recordset.Find "id_user= '" & txtkduser.Text & "'"
If (adouser.Recordset.BOF Or adouser.Recordset.EOF) Then
MsgBox "Id User Tidak ditemukan"
txtkduser.Text = ""
txtkduser.SetFocus
Else
txtnmuser.Text = adouser.Recordset("nm_user")
End If
End Sub
4.b. Detail BArang MAsuk
Option Explicit
Public kodeuser As String
Private Sub bersih()
txtkdbrg.Text = ""
txtnmbrg = ""
txtjumlah = "0"
End Sub
Private Sub cmdbatal_Click()
bersih
End Sub
Private Sub cmdhapus_Click()
Adodetbrgmsk.Recordset.Delete
bersih
End Sub
Private Sub cmdOK_Click()
Adobrgmsk.Recordset.Find "no_masuk = '" & txtnomsk.Text & "'"
Adobrgmsk.Recordset.Update
Unload Me
End Sub
Private Sub cmdtambah_Click()
Adodetbrgmsk.Recordset.AddNew
Adodetbrgmsk.Recordset("no_masuk") = txtnomsk.Text
Adodetbrgmsk.Recordset("kdbrg") = txtkdbrg.Text
Adodetbrgmsk.Recordset("jmlmsk") = txtjumlah.Text
Adodetbrgmsk.Recordset.Update
Adodetbrgmsk.Recordset.Requery
Adodetbrgmsk.Recordset.Filter = "no_masuk='" & txtnomsk.Text & "'"
bersih
adobarang.Recordset.MoveFirst
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If (Not Adodetbrgmsk.Recordset.BOF And Not Adodetbrgmsk.Recordset.EOF) Then
gridtext
End If
End Sub
Private Sub Form_Load()
bersih
End Sub
Private Sub gridtext()
txtkdbrg.Text = Adodetbrgmsk.Recordset("kdbrg")
txtjumlah.Text = Adodetbrgmsk.Recordset("jmlmsk")
End Sub
Private Sub txtkdbrg_LostFocus()
adobarang.Recordset.MoveFirst
adobarang.Recordset.Find "kdbrg='" & txtkdbrg.Text & "'"
If (adobarang.Recordset.BOF Or adobarang.Recordset.EOF) Then
MsgBox "Kode Barang tidak ditemukan"
txtkdbrg.Text = ""
txtkdbrg.SetFocus
Else
txtnmbrg.Text = adobarang.Recordset("nmbrg")
End If
End Sub