VERSION 5.00
Begin VB.Form EditBarang 
   BackColor       =   &H00C0E0FF&
   Caption         =   "Edit Barang"
   ClientHeight    =   3045
   ClientLeft      =   60
   ClientTop       =   750
   ClientWidth     =   6045
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   3045
   ScaleWidth      =   6045
   WindowState     =   2  'Maximized
   Begin VB.ComboBox cboBarang 
      Appearance      =   0  'Flat
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   2040
      TabIndex        =   9
      Top             =   360
      Width           =   2415
   End
   Begin VB.CommandButton cmdEdit 
      BackColor       =   &H00C0FFC0&
      Caption         =   "&Edit"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1440
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   2040
      Width           =   1335
   End
   Begin VB.CommandButton cmdTutup 
      BackColor       =   &H00C0FFC0&
      Caption         =   "T&utup"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   3360
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   2040
      Width           =   1335
   End
   Begin VB.TextBox txtJumlahBarang 
      Appearance      =   0  'Flat
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   2040
      TabIndex        =   2
      Top             =   1440
      Width           =   2055
   End
   Begin VB.TextBox txtHargaBarang 
      Appearance      =   0  'Flat
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   2040
      TabIndex        =   1
      Top             =   1080
      Width           =   3255
   End
   Begin VB.TextBox txtNamaBarang 
      Appearance      =   0  'Flat
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   2040
      TabIndex        =   0
      Top             =   720
      Width           =   3255
   End
   Begin VB.Label Label4 
      BackColor       =   &H00C0E0FF&
      Caption         =   "Jumlah Barang"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   480
      TabIndex        =   8
      Top             =   1440
      Width           =   1455
   End
   Begin VB.Label Label3 
      BackColor       =   &H00C0E0FF&
      Caption         =   "Harga Barang"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   480
      TabIndex        =   7
      Top             =   1080
      Width           =   1455
   End
   Begin VB.Label Label2 
      BackColor       =   &H00C0E0FF&
      Caption         =   "Nama Barang"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   480
      TabIndex        =   6
      Top             =   720
      Width           =   1455
   End
   Begin VB.Label Label1 
      BackColor       =   &H00C0E0FF&
      Caption         =   "Kode Barang"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   480
      TabIndex        =   5
      Top             =   360
      Width           =   1455
   End
   Begin VB.Menu keluar 
      Caption         =   "Keluar"
   End
End
Attribute VB_Name = "EditBarang"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim conAVB As ADODB.Connection
Dim rsBarang As ADODB.Recordset

Private Sub cboBarang_Click()
  Dim strBarang As String
  Dim vntBookMark As Variant
  strBarang = "[Kode Barang] = '" & cboBarang & "'"
    With rsBarang
       .MoveFirst
       .Find strBarang
       txtNamaBarang.Text = ![Nama Barang]
       txtHargaBarang.Text = ![Harga Barang]
       txtJumlahBarang.Text = ![Jumlah Barang]
    End With
   txtNamaBarang.Enabled = True
   txtHargaBarang.Enabled = True
   txtJumlahBarang.Enabled = True
   cmdEdit.Enabled = True
End Sub

Private Sub cmdEdit_Click()
  On Error GoTo HandleErrors
   With rsBarang
    ![Kode Barang] = cboBarang.Text
    ![Nama Barang] = txtNamaBarang.Text
    ![Harga Barang] = txtHargaBarang.Text
    ![Jumlah Barang] = txtJumlahBarang.Text
    .Update
  End With
  cmdEdit.Enabled = False
  txtNamaBarang.Enabled = False
  txtHargaBarang.Enabled = False
  txtJumlahBarang.Enabled = False
  
   With rsBarang
    While Not .EOF
      If Not .BOF Then
        cboBarang.Clear
        .MoveNext
      End If
    Wend
  End With
  
  With rsBarang
    .MoveFirst
    While Not .EOF
      If Not .BOF Then
        cboBarang.AddItem ![Kode Barang]
        .MoveNext
      End If
    Wend
  End With
cmdEdit_Click_Exit:
  Exit Sub

HandleErrors:
  Dim strMessage As String
   Dim errDBError As ADODB.Error
   For Each errDBError In conAVB.Errors
     strMessage = strMessage & errDBError.Description & vbCrLf
   Next
   MsgBox strMessage, vbExclamation, "Provider Error"
   On Error GoTo 0
End Sub

Private Sub cmdTutup_Click()
  Unload Me
End Sub

Private Sub Form_Load()
  Dim strSQL As String
  Set conAVB = New ADODB.Connection
    conAVB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Persist Security info=False;Data source =" & App.Path & _
    "\AVB.mdb;mode = readwrite"
    conAVB.Open
  Set rsBarang = New ADODB.Recordset
  strSQL = "SELECT * FROM Barang"
    rsBarang.Open strSQL, conAVB, adOpenDynamic, adLockOptimistic, adCmdText
  On Error GoTo 0
  With rsBarang
    While Not .EOF
      If Not rsBarang.BOF Then
        cboBarang.AddItem ![Kode Barang]
        .MoveNext
      End If
    Wend
  End With
End Sub

Private Sub keluar_Click()
  Unload Me
End Sub

Private Sub txtNamaBarang_KeyPress(KeyAscii As Integer)
   KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
