Baca Juga
Biar nyambung baca dulu artikel saya sebelumnya untuk membuat Form Menu, Form New Password dan Form edit Password. Sekarang kita membuat Form Delete Password, Tambahkan sebuah Form (Namai dengan : FrmDelPassword), tambahkan beberapa component sebagai berikut :
- 2 buah CommandButton
- sebuah TextBox
- sebuah Frame
- sebuah Label
Susun sedemikian rupa hingga tampilannya akan nampak seperti ini :
- command1, name : Command1, caption : Create Password, enabled = false
- command2, name : Command2, caption : Cancel
- Text1, name : Text1, Text : , PasswordChar : *
- Label1, name : Label1, caption : Old Password
Form Delete Password
Sekarang diteruskan untuk mengisi jendela coding
Private Sub Command1_Click()
On Error GoTo 1
Dim db As Database
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile FrmMenu.Text1.Text, FrmMenu.Text2.Text
Set db = OpenDatabase(FrmMenu.Text2.Text, True, False, ";pwd=" + Text3.Text)
db.newPassword Text1.Text, ""
db.Close
MsgBox "Password has been deleted!", vbInformation, ".: Password deleted success"
Unload Me
1:
If Not Err.Number = 0 Then
MsgBox Err.Number, vbInformation, ".: Password Changed failed"
Exit Sub
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Text1_Change()
On Error GoTo 1
Command1.Enabled = True
Dim db As Database
Set db = OpenDatabase(FrmMenu.Text1.Text, True, False, ";pwd=" + Text1.Text)
1:
If Not Err.Number = 0 Then
Command1.Enabled = False
End If
End Sub
On Error GoTo 1
Dim db As Database
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile FrmMenu.Text1.Text, FrmMenu.Text2.Text
Set db = OpenDatabase(FrmMenu.Text2.Text, True, False, ";pwd=" + Text3.Text)
db.newPassword Text1.Text, ""
db.Close
MsgBox "Password has been deleted!", vbInformation, ".: Password deleted success"
Unload Me
1:
If Not Err.Number = 0 Then
MsgBox Err.Number, vbInformation, ".: Password Changed failed"
Exit Sub
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Text1_Change()
On Error GoTo 1
Command1.Enabled = True
Dim db As Database
Set db = OpenDatabase(FrmMenu.Text1.Text, True, False, ";pwd=" + Text1.Text)
1:
If Not Err.Number = 0 Then
Command1.Enabled = False
End If
End Sub
NOTE :
Aplikasi ini dirancang untuk mem-password, dengan terlebih dahulu mengcopy database asli ke path yang lain, untuk menghindari hal-hal yang tidak diinginkan.