0% found this document useful (1 vote)
316 views

Rumus Coding

1. The Form Create User allows a user to create, edit, and delete user accounts. It contains fields for username, password, status, and buttons to save, clear, and delete records. Validation checks for empty fields and duplicate usernames are also included. 2. The Form Login contains fields for a user to enter their username and password. When the login button is clicked, it checks the credentials against the database and either loads the menu form or displays an error. 3. The Form Menu contains a single button to open the Form Create User for account management.

Uploaded by

Riza Rizkiyanto
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
316 views

Rumus Coding

1. The Form Create User allows a user to create, edit, and delete user accounts. It contains fields for username, password, status, and buttons to save, clear, and delete records. Validation checks for empty fields and duplicate usernames are also included. 2. The Form Login contains fields for a user to enter their username and password. When the login button is clicked, it checks the credentials against the database and either loads the menu form or displays an error. 3. The Form Menu contains a single button to open the Form Create User for account management.

Uploaded by

Riza Rizkiyanto
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

Form Create User


Dim proses As String
Private Sub cedit_Click()
proses = "edit"
Call kosong
tusername.SetFocus
End Sub
Private Sub cexit_Click()
formcreate.Hide
End Sub
Private Sub chapus_Click()
If chapus.Caption = "&Hapus" Then
proses = "Hapus"
tusername.SetFocus
chapus.Caption = "&Ok"
Else
If chapus.Caption = "&Ok" Then
adocreate.RecordSource = "select * from tcreateuser where user_name='" + tusername.Text + "' and
Password='" + tconfirm.Text + "' and Status='" + cstatus.Text + "'"
adocreate.Refresh
If Not adocreate.Recordset.EOF Then
If proses = "Hapus" Then
adocreate.Recordset.Delete
MsgBox "Remove User Berhasil"
chapus.Caption = "&Hapus"
Call kosong
Else
MsgBox "Belum Ada"
End If
Else
MsgBox "Ra ono"
Call kosong
End If
chapus.Caption = "&Hapus"
End If
End If
End Sub
Private Sub cinput_Click()
proses = "input"
Call kosong
tusername.SetFocus
End Sub
Private Sub csimpan_Click()
If tpassbaru.Text <> tconfirm.Text Then
MsgBox "Anda Salah Memasukan Konfirmasi Password"
tconfirm.Text = ""
tconfirm.SetFocus
Exit Sub
End If

If tusername.Text = "" Or tpassbaru.Text = "" Or tconfirm.Text = "" Or cstatus.Text = "" Then


MsgBox "Harap Isi User Name,Password dan Status"
Exit Sub
End If
If MsgBox("Sutuju Untuk Disimpan?", vbQuestion + vbYesNo, "Simpan Data") = vbYes Then
If cstatus.Text = "USER" Then

adocreate.RecordSource = "select * from tcreateuser where user_name='" + tusername.Text + "'"


adocreate.Refresh

If Not adocreate.Recordset.EOF Then


If proses = "input" Then
MsgBox "User Name ='" + tusername.Text + "'Sudah Terdaftar"
Exit Sub
End If
Else
If proses = "input" Then
GoTo a
End If
End If

End If
If proses = "edit" Then
GoTo d
End If
a:
adocreate.RecordSource = "select *from tcreateuser where Status='" + cstatus.Text + "'"
adocreate.Refresh
If Not adocreate.Recordset.EOF Then
If Not proses = "edit" Then
If adocreate.Recordset!Status = "ADMIN" Or adocreate.Recordset!Status = "admin" Then
MsgBox "Status Admin Sudah Ada,Silahkan Pilih Hak Akses Yang Lain!", vbInformation, "Pesan"
Exit Sub
End If
End If
End If
GoTo p
d:
adocreate.RecordSource = "select *from tcreateuser where user_name='" + tusername.Text + "'"
adocreate.Refresh
p:

With adocreate.Recordset
If proses = "input" Then
.AddNew
End If
!user_name = tusername.Text
!Password = tconfirm.Text
!Status = cstatus.Text
.Update
Call kosong
End With
Else
Call kosong
tusername.SetFocus
End If
End Sub
Private Sub cstatus_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
If cstatus.Text = "" Then
MsgBox "Pilih Status"
Else
If proses = "Hapus" Then
chapus.SetFocus
Exit Sub
End If
csimpan.SetFocus
End If
End If
End Sub
Private Sub tconfirm_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If tconfirm.Text = "" Then
MsgBox "Masukan Confirm Password"
Else
cstatus.SetFocus
End If
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If Text1.Text = "" Then
MsgBox "MASUKAN NIP"
Else
csimpan.SetFocus
End If
End If
End Sub

Private Sub tpassbaru_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If tpassbaru.Text = "" Then
MsgBox "Harap Isi Password"
Else
tconfirm.SetFocus
End If
End If
End Sub
Private Sub tpasslama_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If tpasslama.Text = "" Then
MsgBox "Masukan Password Lama Anda"
Else
With adocreate.Recordset
If tpasslama.Text <> !Password Then
MsgBox "Password Yang Anda Masukan Salah"
Call kosong
tusername.SetFocus
Else
If proses = "Hapus" Then
tconfirm.SetFocus
tpassbaru.Enabled = False
Exit Sub
End If
tpassbaru.Enabled = True
tpassbaru.SetFocus
End If
End With
End If
End If
End Sub

Private Sub tusername_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If tusername.Text = "" Then
MsgBox "Isi User"
Else
adocreate.RecordSource = "select * from tcreateuser where user_name='" + tusername.Text + "'"
adocreate.Refresh

If Not adocreate.Recordset.EOF Then


If proses = "input" Then
MsgBox "User Name ='" + tusername.Text + "'Sudah Terdaftar"
Exit Sub
End If

With adocreate.Recordset
tusername.Text = !user_name
End With

If proses = "edit" Then


tpasslama.Enabled = True
tpasslama.SetFocus
End If
If proses = "Hapus" Then
tpasslama.Enabled = True
tpasslama.SetFocus
End If
Else
If proses = "input" Then
tpasslama.Enabled = False
tpassbaru.Enabled = True
tpassbaru.SetFocus
Else
MsgBox "User Name='" + tusername.Text + "'Tidak Ada"
Call kosong
tusername.SetFocus
End If
End If
End If
End If
End Sub

Public Sub kosong()


tusername.Text = ""
tpasslama.Text = ""
tpassbaru.Text = ""
tconfirm.Text = ""
cstatus.Text = ""
End Sub

Public Sub edit()


With adocreate.Recordset
If proses = "edit" Then
If tpassbaru.Text <> tconfirm.Text Then
MsgBox "Confirm Password Salah"
tconfirm.Text = ""
tconfirm.SetFocus
Exit Sub
End If
!user_name = tusername.Text
!Password = tconfirm.Text
!Status = cstatus.Text
!kode = Text1.Text
.Update
End If
End With
End Sub

2. Form Login
Private Sub Command1_Click()
adopass.RecordSource = "select * from tcreateuser where user_name='" + tuser.Text + "' and
Password='" + tpass.Text + "' "
adopass.Refresh
If Not adopass.Recordset.EOF Then
With adopass.Recordset
formmenu.Refresh
formmenu.Show
Me.Hide
End With
Else
MsgBox "Password/User/Status Anda Salah"
tuser.Text = ""
tpass.Text = ""
End If
End Sub
Private Sub Command2_Click()
Me.Hide
End Sub
Private Sub tpass_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If tpass.Text = "" Then
MsgBox "Masukan Password"
Else
Command1.SetFocus
End If
End If
End Sub
Private Sub tuser_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If tuser.Text = "" Then
MsgBox "Masukan User Name Anda"
Else
tpass.SetFocus
End If
End If
End Sub

3. Form Menu
Private Sub creat_Click()
formcreate.Show
End Sub

You might also like