Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access - Capturing the name of the form or report 1

Status
Not open for further replies.

chippyles

Technical User
Nov 10, 2004
49
US
I have an Append query that currently captures data when a user OPENS a form or a report. The name of the user (USER: Environ("username")), the timestamp (DATE: Now()), and the Host (HOST: Environ("COMPUTERNAME")) are what I am currently capturing. I am looking to add one more field (Task) and I want the name of the form or the report the person uses.

So when person X on computer xyz opens form ABC at 12 am it should capture the data and do the append query.

USER = X
HOST = xyz
DATE = 01/01/2001 12:00:00 AM
TASK = ABC
 
in a module enter the following code
be careful with all the single and double quotes
and on the properties tab of the form enter =logform()
Public Function logform()
With DoCmd
.SetWarnings False
.RunSQL "INSERT INTO LOG_REPORT ([DATE],[USER],HOST,TASK)SELECT Now(),'" & Environ("username") & "','" & Environ("COMPUTERNAME") & "','" & ActiveForm.Name & "'"
.SetWarnings True
End With
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top