This topic is locked

Updating values dynamically

5/4/2005 11:59:32 AM
ASPRunnerPro General questions
skemp author

How may I update a field with a system value....for example: I would like to have the system automatically fill in the username who edited the record and save that username in the table being updated.
Any help is greatly appreciated.
Sheryl Kemp

A
aspbeginner 5/4/2005

in the ..._functions.asp page find the following function:

function GetDefaultValue(strField)
insert the following in the quotes for the field you want to automatically update (example)

(original)

if strField="yourfield" then GetDefaultValue = "" end if

(modified)

if strField="yourfield" then GetDefaultValue = Session("UserID") end if
replace "yourfield" with the filed from your database

you can also have the time inserted with the username as follows
if strField="yourfield" then GetDefaultValue = Session("UserID") & " " & now() end if
Also when building your pages make this file hidden so that the users does not change the default data

501203 5/4/2005

Great! Thank you very much.
May I also update the date in which the edit occurred with the current datetime?
Sheryl

skemp author 5/4/2005

I just realized that you already answered my datetime question too. Sorry.
Thank you sooo much for your help!