User Account Form - Encrypted password

kroeger

Registered User.
Local time
Today, 10:11
Joined
Apr 13, 2014
Messages
39
Hi,

I am using an RC4 vba function to encrypt the password when a user account is setup in the front end of my split database. The password is stored in the backend encrypted. It is encrypted in the before update event of the form by calling a function against the bound password field. My problem is that when I want to maintain user accounts using this form, I want to be able to see the password as plain text.

I can decrypt it and display it in the form in plain text but cannot update it. This is because to display the password in plain text requires me to use a query as the record source for the form and this query requires an expression to call the decrypt function against the password field. The form will not allow any changes against a field that uses an expression as the control source.

Any ideas?
 
You're going to have to use oncurrent and afterupdate events to populate your form. I think hahaha
 
Thanks for the tip, I will look into this.
 
Update,

Thanks BluIshDan. I have used the On Current event to decrypt the password. The password now displays as plain text and is encrypted again when the before update event triggers. I have been struggling with this all day!!!! :)
 
research an events trigger before you start to code. I don't know if it is the right one you may need, it was just a conceptually correct guess! haha
 
A bit blurry of an image but it works! lol
attachment.php


The AfterUpdate event occurs after changed data in a control or record is updated.
Syntax

expression.AfterUpdate

expression A variable that represents a Form object.

Remarks


Changing data in a control by using Visual Basic or a macro (macro: An action or a set of actions that you can use to automate tasks. Macros are recorded in the Visual Basic for Applications programming language.) containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's (form: An Access database object on which you place controls for taking actions or for entering, displaying, and editing data in fields.)AfterUpdate event does occur.

To run a macro or event procedure (event procedure: A procedure that is automatically executed in response to an event initiated by the user or program code, or that is triggered by the system.) when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus (focus: The ability to receive user input through mouse or keyboard actions or the SetFocus method. Focus can be set by the user or by the application. The object that has focus is usually indicated by a highlighted caption or title bar.) or when the user presses ENTER or TAB.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control (calculated control: A control that is used on a form, report, or data access page to display the result of an expression. The result is recalculated each time there is a change in any of the values on which the expression is based.).AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For bound controls (bound control: A control used on a form, report, or data access page to display or modify data from a table, query, or SQL statement. The control's ControlSource property stores the field name to which the control is bound.), the OldValue property isn't set to the updated value until after the AfterUpdate event for the form occurs. Even if the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

Note
To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.
 

Attachments

  • AfterUpdate.jpg
    AfterUpdate.jpg
    102.7 KB · Views: 184

Users who are viewing this thread

Back
Top Bottom