Pls. help me how to code in changing the account using your old password replacing a new password with match to all datas in database? Unsaon man pghimu sa dtpicker nga dili xa pwede ka click sa niagi nga dates?
Pls. help me how to code in changing the account using your old password replacing a new password with match to all datas in database? Unsaon man pghimu sa dtpicker nga dili xa pwede ka click sa niagi nga dates?
i'm not an expert but let me try. concept lang ni ha. this may vary a little sa actual codes.
DTPicker:
1. if you don't want to select a date later than the current date.
Private Sub DTPicker1_Change()
If DTPicker1.Value < Now Then
MsgBox "You are not allowed to select previous dates.", vbInformation
DTPicker1.Value = Now
End If
End Sub
2. if you don't want to select previously selected dates then store it in your database for lookup (ikaw na balaha sa code).
please elaborate your question on password thing kay medyo wa ko kasabot.
bro mao ra gyud ni ako ika hinabang nimu.
Just text me if you have problem understanding the code and give me your landline so i can give you a detail explanation for the code.
See the code below...
'************************************************* **************************************
' Module : Form1
' DateTime : 10/18/2006 18:21
' Author : dlanyer77
' Purpose : for changing password
'************************************************* **************************************
Option Explicit
Private strSQL As String
Private Const SysInf As String = "System Information"
Private Type MyValidation
password As String
passwordExist As Boolean
End Type
Private Sub cmdChangeNow_Click()
Dim PwdConfirm As MyValidation
On Error GoTo ErrHandler
OracleDBConnect.BeginTrans
If txtNewPassword.Text = txtNewPWordConfirm.Text Then
PwdConfirm = PasswordConfirm(Currentuser.IDNumber)
If PwdConfirm.passwordExist Then
If PwdConfirm.password = txtCurrentPassword.Text Then
strSQL = "UPDATE pass_lib " & _
"SET password = '" & txtNewPassword.Text & "' " & _
"WHERE idnumber = " & Currentuser.IDNumber
OracleDBConnect.Execute strSQL
MsgBox "Password changed!", vbInformation, SysInf
Else
MsgBox "Invalid password!", vbExclamation, SysInf
End If
End If
Else
MsgBox "New Password not match!", vbExclamation, SysInf
End If
OracleDBConnect.CommitTrans
Exit Sub
ErrHandler:
OracleDBConnect.RollbackTrans
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdChangeNow_Click of Form Form1", vbExclamation, SysInf
Exit Sub
End Sub
Private Function PasswordConfirm(ByVal lngValue As Long) As MyValidation
Dim rec As New ADODB.Recordset
On Error GoTo ErrHandler
strSQL = "SELECT password " & _
" FROM pass_lib " & _
" WHERE idnumber = " & lngValue
rec.Open strSQL, OracleDBConnect
If Not rec.EOF Then
PasswordConfirm.passwordExist = True
PasswordConfirm.password = rec!password
Else
PasswordConfirm.passwordExist = False
End If
rec.Close
Set rec = Nothing
Exit Function
ErrHandler:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure PasswordConfirm of Form Form1", vbExclamation, SysInf
Exit Function
End Function
dont expect me to explicitly solve ur problem hehe anyway here's some overview of some possible workaround:Originally Posted by aelleah
Changing account is easy:
Consider you have this traditional format:
Three textboxes:
txtpass(1) is for Old password
txtpass(2) is for New Password
txtpass(3) is for Confirm New Password
Commandbutton1 is for Update
your callupdatepass may look like this:Code:Private Sub Commandbutton1_Click(Index As Integer) Select Case Index Case 0 If txtPass(1).Text <> txtPass(2).Text Or txtPass(2).Text <> txtPass(1).Text Then MsgBox "<Confirm New Password> did not match with the <New Password> ", vbInformation, Me.Caption txtPass(2).SetFocus Exit Sub Else Call updatePass End If Case 1 Unload Me End Select End Sub
for the datepicker problem for me i found it unlogical to solve bcoz datepicker usually serves as date filter's instead of pre empted conditionsCode:Private Sub updatePass() Dim rs As New ADODB.Recordset Dim msg As String On Error GoTo err_Handler msg = MsgBox("Are you sure you want to modify this record?", vbYesNo) If msg = vbYes Then Set rs = cnSQL.Execute("update vfiuseraccess " & _ "set username = '" & txtPass(4).Text & "'," & _ "name = '" & txtPass(5).Text & "'," & _ "passwrd = '" & Encrypt(txtPass(1).Text) & "'," & _ "mrs = '" & txtPass(7).Text & "'," & _ "mis = '" & txtPass(8).Text & "'," & _ "users = '" & txtPass(9).Text & "'," & _ "security = " & txtPass(6).Text & _ " WHERE usercode = " & Val(txtPass(3).Text)) MsgBox "Record was updated successfully ", vbInformation, Me.Caption Unload Me rfrsh Else MsgBox "Cancel was selected ", vbInformation, Me.Caption Exit Sub End If Exit Sub err_Handler: MsgBox err.Description, vbInformation, Me.Caption End Sub
@ebyong
bro for me dili man necessary nga e set pa ang rs sa updatePass nga procedure kay pwede man nimu e execute directly also its a good practice to destroy the recordset before exit sub to release the object and to free-up the memory (thats vb code tuning). lastly, i think making a control array is not a good practice (vb code tuning again). share lang ko bro ha. peace!
how sure you are hehe anyway this are just workaround no need to blow ur semantics for in the first place as i said i dont want to reiterate the solution of the problem at least im making a fairview of the scenario and also did u see my unload code for u to say that im not killing any recordset? anyway bro ur damned good i hope u could share some semantics for us to obey PEACE!Originally Posted by dlanyer77
Similar Threads |
|