sorry,, I figure it my self.. thank all..
Code:
Sub CmdUbah_Click()
If CmdUbah.Caption = "Ubah" Then
edUID = Me.UserCariSubForm!UID
If Not (edUID = Error) Then
edUserID = TextUserID.Value
adNamaLengkap = TextNamaLengkap.Value
adPassword = TextPassword.Value
adGrup = TextGrup.Value
adKeterangan = TextKeterangan.Value
adPertanyaan = TextPertanyaan.Value
adJawaban = TextJawaban.Value
TextUserID.ControlSource = ""
TextNamaLengkap.ControlSource = ""
TextPassword.ControlSource = ""
TextGrup.ControlSource = ""
TextKeterangan.ControlSource = ""
TextPertanyaan.ControlSource = ""
TextJawaban.ControlSource = ""
TextUserID.Value = edUserID
TextNamaLengkap.Value = adNamaLengkap
TextPassword.Value = adPassword
TextGrup.Value = adGrup
TextKeterangan.Value = adKeterangan
TextPertanyaan.Value = adPertanyaan
TextJawaban.Value = adJawaban
CmdUbah.Caption = "Simpan"
CmdHapus.Caption = "Batal"
CmdTambah.Visible = False
End If
ElseIf CmdUbah.Caption = "Simpan" Then
Dim RstUbah As Recordset
Set RstUbah = CurrentDb.OpenRecordset("Set-User", dbOpenDynaset)
With RstUbah
.FindFirst "[Login] = '" & TextUserID.Value & "'"
If .NoMatch Then
.FindFirst "[Nama] = '" & TextNamaLengkap.Value & "'"
If .NoMatch Then
UbahNama
Else
If !UID = TextUserID Then
UbahNama
Else
MsgBox "Nama ini sudah digunakan, harap memilih Nama yang lain1"
End If
End If
Else
If !UID = edUID Then
.FindFirst "[Nama] = '" & TextNamaLengkap.Value & "'"
If .NoMatch Then
UbahNama
Else
If !UID = TextUserID Then
UbahNama
Else
MsgBox "Nama ini sudah digunakan, harap memilih Nama yang lain2"
End If
End If
Else
MsgBox "User ID ini sudah digunakan, harap memilih User ID yang lain3"
End If
End If
.Close
End With
Set RstUbah = Nothing
Reset
End If
End Sub
correction is Set RstUbah = CurrentDb.OpenRecordset("Set-User", dbOpenDynaset)
Code:
Sub UbahNama()
Dim RstEdit As Recordset
Set RstEdit = CurrentDb.OpenRecordset("Set-User", dbOpenDynaset)
With RstEdit
.FindFirst "UID = " & edUID
.Edit
![Login] = TextUserID.Value
![Nama] = TextNamaLengkap.Value
![Password] = TextPassword.Value
![Grup] = TextGrup.Value
![Keterangan] = TextKeterangan.Value
![Pertanyaan] = TextPertanyaan.Value
![Jawaban] = TextJawaban.Value
varUbah = MsgBox("Simpan pengaturan user ini", 68, "Informasi")
If varUbah = 6 Then
.Update
'MsgBox "Tersimpan"
CmdTambah.Visible = True
CmdUbah.Caption = "Ubah"
End If
.Close
End With
Set RstEdit = Nothing
End Sub