Punya Account Blogger?
Posted by Sofyan SOX on Kamis, 06 Mei 2010 in




Sub bersih()
  tuser.Text = ""
  tpass.Text = ""
  cblevel.Text = ""
End Sub

Sub aktif()
  tuser.Enabled = 1
  tpass.Enabled = 1
  cblevel.Enabled = 1
End Sub

Sub nonaktif()
  tuser.Enabled = 0
  tpass.Enabled = 0
  cblevel.Enabled = 0
End Sub

Sub simpan()
 With Data1.Recordset
     !UserName = tuser.Text
     !Password = tpass.Text
     !Level = cblevel.Text
 End With
End Sub

Sub tampil()
 With Data1.Recordset
    tuser.Text = !UserName
    tpass.Text = !Password
    cblevel.Text = !Level
 End With
End Sub

Sub awal()
  bersih
  nonaktif
  cnew.SetFocus
End Sub

Private Sub ccari_Click()
Dim cari As String
cari = InputBox("Masukan username : ")
  Data1.Recordset.FindFirst "username = '" & cari & "'"
  If Data1.Recordset.NoMatch Then
     MsgBox "data Ga ada"
  Else
     aktif
     tampil
  End If
End Sub

Private Sub cclose_Click()
 If MsgBox("Keluar ?", vbYesNo) = vbYes Then Unload Me
End Sub

Private Sub cdel_Click()
 If tuser.Text = "" Or tpass.Text = "" Or cblevel.Text = "" Then
    MsgBox "Lengkapi Data"
 Else
  Data1.Recordset.Delete
  MsgBox "data terhapus"
 End If

 awal
End Sub

Private Sub cedit_Click()
 If tuser.Text = "" Or tpass.Text = "" Or cblevel.Text = "" Then
    MsgBox "Lengkapi Data"
 Else
  Data1.Recordset.Edit
     simpan
  Data1.Recordset.Update
  MsgBox "Update Success"
  awal
 End If
End Sub

Private Sub cnew_Click()
  bersih
  aktif
  tuser.SetFocus
End Sub

Private Sub csave_Click()
 If tuser.Text = "" Or tpass.Text = "" Or cblevel.Text = "" Then
    MsgBox "Lengkapi Data"
 Else
  Data1.Recordset.AddNew
    simpan
  Data1.Recordset.Update
  MsgBox "Data Tersimpan"
  awal
 End If
End Sub




Private Sub Form_Activate()
  awal
End Sub

Private Sub tuser_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  Data1.Recordset.FindFirst "username = '" & tuser.Text & "'"
  If Data1.Recordset.NoMatch Then
     MsgBox "data Ga ada"
  Else
     tpass.Text = Data1.Recordset!Password
     cblevel.Text = Data1.Recordset!Level
  End If
End If
End Sub

1 Response to “VB database ( Data User )”:

Posting Komentar