Tempo hari ada pengunjung menanyakan bagaimana memberi password dengan Vis-Data, saya bilangnya "..pending dulu ya!" padahal saya ga bisa, saya tanyakan di mbah google pun jawabnya malah nggak karuan, yang nyari kurang pinter kali ya.. ^_^. Mungkin ada fasilitasnya, hanya saja saya belum tahu, mungkin ada teman-teman yang tahu mohon di share ya.
Apa boleh buat, pakai coding saja ya. Yuph kita akan membuat aplikasi sendiri untuk me-manage Database kita.
Buat project baru (standart-EXE), Kemudian tambahkan references (Menu : Project-References ...) Microsoft DAO 3.51 Object Library, dan tambahkan component (Menu : Project-components ..) Microsoft Common Dialog Control 6.0 (SP3)
Form Menu
Tambahkan sebuah Form (Namai dengan : FrmMenu), tambahkan beberapa component sebagai berikut :
- 6 buah CommandButton
- 2 buah TextBox
- 1 buah CommonDialog
- dan beberapa Label
Set properties-nya sebagai berikut :
Susun sedemikian rupa hingga tampilannya akan nampak seperti ini :
- command1, name : Command1, caption : New Password, enabled = false
- command2, name : Command2, caption : Edit Password, enabled = false
- command3, name : Command3, caption : Delete Password, enabled = false
- command4, name : Command4, caption : Browse ...
- command5, name : Command5, caption : Browse ...
- command6, name : Command6, caption : Exit
- Text1, name : Text1, Text : , Locked = True
- Text2, name : Text2, Text : , Locked = True
- Label1, name : Label1, caption : Password :
- Label2, name : Label2, caption : NO
- Label3, name : Label3, caption : Source File
- Label4, name : Label4, caption : Destination File
Form Menu
Sudah rapi ? nah sekarang kita mulai codingnya :
Private Sub Command1_Click()
FrmNewPassword.Show 1
End Sub
Private Sub Command2_Click()
FrmEditPassword.Show 1
End Sub
Private Sub Command3_Click()
FrmDelPassword.Show 1
End Sub
Private Sub Command4_Click()
CommonDialog1.InitDir = App.Path + "\Data\"
CommonDialog1.Filter = "Access Database|*.mdb"
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
cek CommonDialog1.FileName
End Sub
Private Sub Command5_Click()
CommonDialog1.InitDir = App.Path + "\"
CommonDialog1.Filter = "Access Database|*.mdb"
CommonDialog1.ShowSave
Text2.Text = CommonDialog1.FileName
End Sub
Sub cek(fdb As String)
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
On Error GoTo 1
Dim db As DAO.Database
Set db = OpenDatabase(fdb)
Command1.Enabled = True
Label2.Caption = "NO"
1:
If Not Err.Number = o Then
Command2.Enabled = True
Command3.Enabled = True
Label2.Caption = "YES"
End If
End Sub
Private Sub Command6_Click()
End
End Sub
Private Sub Form_Load()
Text2.Text = App.Path + "\" + Format(Now, "YYmmDD") + ".mdb"
End Sub
FrmNewPassword.Show 1
End Sub
Private Sub Command2_Click()
FrmEditPassword.Show 1
End Sub
Private Sub Command3_Click()
FrmDelPassword.Show 1
End Sub
Private Sub Command4_Click()
CommonDialog1.InitDir = App.Path + "\Data\"
CommonDialog1.Filter = "Access Database|*.mdb"
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
cek CommonDialog1.FileName
End Sub
Private Sub Command5_Click()
CommonDialog1.InitDir = App.Path + "\"
CommonDialog1.Filter = "Access Database|*.mdb"
CommonDialog1.ShowSave
Text2.Text = CommonDialog1.FileName
End Sub
Sub cek(fdb As String)
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
On Error GoTo 1
Dim db As DAO.Database
Set db = OpenDatabase(fdb)
Command1.Enabled = True
Label2.Caption = "NO"
1:
If Not Err.Number = o Then
Command2.Enabled = True
Command3.Enabled = True
Label2.Caption = "YES"
End If
End Sub
Private Sub Command6_Click()
End
End Sub
Private Sub Form_Load()
Text2.Text = App.Path + "\" + Format(Now, "YYmmDD") + ".mdb"
End Sub
Langkah selanjutnya membuat Form NewPassword
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :