Changing Environ field automatically in report.

usmanghani_2654

New member
Local time
Today, 08:54
Joined
May 8, 2012
Messages
8
Hi there,
I have an Access database (.accdb) that has table, form and report. The field in all are the same. The user interacts with the Form only and enters data to it. Table is a back-end thing and no-one goes to it. However, in Form there is a button that when pressed, prints the report for that relevant form/record which we then give to customers.

Now, I have a field in report (like a signature field) that mentions the name of the user who printed that report. Lets say, Mr X did the data entry and then printed the report and gave it to the customer. After that customer loses the report and comes back for a copy of the report, but now Mr Y is at the desk and issues the report. Obviously Mr Y doesn't have to do the data entry again because record is there and Mr Y has the access to it, so he just presses the print report button and prints the report. What I would like is that the signature field should update itself if anyone else (in this case Mr Y) accesses the database and prints the report for that specific record.

Any solution please...!!!
Regards.
 
If you haven't got a solution for this already... one way is to create a function and call that in the report:

Function:
Code:
Public Function Uname()

Uname = Environ("Username")

End Function

set the control source of your textbox to: =uname()
 
Here is a suggestion to accomplish your aim. It requires an API call.
http://stackoverflow.com/questions/...ba-code-to-only-fire-when-physically-printing

BTW
by the way, the Signature field reads the user's login Username, i.e., Environ

Environ("Username") doesn't read the username. It reads the Username environment variable. The word "variable" is important. It means it can be changed. It is easily done by the user.

Read the actual username if you want security.

Code:
CreateObject("wscript.network").UserName
 

Users who are viewing this thread

Back
Top Bottom