[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Add data to table field when record is modified

Posted on 2015-01-13
4
Medium Priority
?
235 Views
Last Modified: 2015-01-13
I have two field in a table...  LastModUser (short text field) and LastModDate (short date field).  When the record is either added or modified I want the LastModUser  field to be populated with the user's login and I want the LastModDate field to be populated with the current date (short date).

How can I do this?  I assume it will be in the beforeupdate event of the record?  Or?

--Steve
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
PatHartman earned 1000 total points
ID: 40546719
The code goes into the BeforeUpdate event of the Form.
In my apps, the code is always:
    Me.ChangeBy = Forms!frmLogin!txtEmpID
    Me.ChangeDT = Now()

Open in new window

Because I keep the login form open (but hidden).  Where you get the LoginID depends on how the user logs in and what you do with the information he provides.

PS - the datetime data type is a double precision number with the integer being the number of days since 12/30/1899 and time being the time of day.  Formatting is a visual thing and is done when the date is displayed on a form or report.  I use Now() because I prefer to include time of day in my "timestamps" but the Date() function will just return the current date so you can use that if you prefer.  TOD is especially important in my current app because we have to extract updates and send them off to the State of Connecticut.  Our extract runs at 8 PM and selects anything that was updated after the last extract.  So if something is updated at 8:05 it doesn't get sent until the following day.
0
 

Author Comment

by:SteveL13
ID: 40546726
Pat,

I should have been more specific regarding the LastModUser field.  I meant the computer logic name.  There is no database login form.  How would I do that?
0
 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1000 total points
ID: 40546864
You can grab the computer's login name with this:

Environ("UserName")

Or use the API:

https://support.microsoft.com/kb/161394/en-us
0
 

Author Closing Comment

by:SteveL13
ID: 40546971
Both very helpful.  Thank you.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question