I'm attempting to auto add a unique value to a text field [TktNo] via a Form. I'm using VBA code to accomplish this. Below is the code...
In the code, I'm taking the first character from the current date [DateCreated], the first character from the user that created the record [CreatedBy] and I'm adding the Unique ID for the record [RefNo] (all fields in the same table).
The [DateCreated] field is automatically generated via "DateNow()". Likewise, the [CreatedBy] field is automatically added via "CurrentUser".
The problem that I have is that the code is placed in the "Before Update" of the Form which results in the TktNo being updated/changed everytime a user updates the record - and I do NOT want the TktNo to be updated (ever).
I tried adding the code to "Before Insert" but then the Ref No and Date Created info isn't available.
Please help... I should also note that I do NOT know how to write VBA code. I'm open to alternative methods to adding a unique value to the TktNo field that would not require me to make major changes to the DB or table structure.
Code:TktNo.Value = VBA.Left(DateCreated.Value, 1) & VBA.Left(CreatedBy.Value, 1) & RefNo.Value