Solved

print name or id of person running access report

Posted on 2012-03-30
14
345 Views
Last Modified: 2012-04-10
Is there a way to print on a report the ID of the person who ran the report?
0
Comment
Question by:LindaOKSTATE
[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
  • 6
  • 4
  • 2
  • +1
14 Comments
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 34 total points
ID: 37788677
Print where?


In a textbox do this as the controlsource

=CurrentUser()
0
 
LVL 20

Assisted Solution

by:clarkscott
clarkscott earned 33 total points
ID: 37788681
I think the only way to do this would be to code the app so someone clicks a button on a form to run the report.
There's code to determine each users SIGNON to the system and you could write code to add a record to a table each time someone clicks the button.

Are you interested in this solution?  If so, I can provide the code for determining a users signon name.

Scott C
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 37788696
Here you go...
Paste this function into your project:

Function CName() As String
'This function will get the login user ID of the person logged into the computer    Dim strUserName As String
    Dim x
    Set x = CreateObject("WSCRIPT.Network")
    CName = UCase(x.UserName)    
End Function

In the declaration section:  make CNAME a public variable:

public CNAME as string


Now, create a table with CNAME, DATE fields.   When the user clicks the button (on a form) to run the report, prior to (or after) the report is run  write the code to add a record to your table.  

rst!CNAME = CNAME()
rst!DateField = NOW()

Scott C
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 20

Expert Comment

by:clarkscott
ID: 37788702
sorry for adding the comment "'This function will get the login user ID of the person logged into the computer    Dim strUserName As String"  in the code.  It really doesn't apply here.

Scott C
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37788713
Yeah, Scott I missed the "ID" part... (Not CurrentUser)

I am sure you can take it form here...

enjoy the weekend

;-)

Jeff
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 37788714
further... actually, you don't need to make the CNAME a public variable.  The function will return the name.

(PS.  I grabbed this code from an existing app and other things apply that I didn't consider and don't apply to your scenario.  Sorry for that confusion.)

Scott C
0
 

Author Comment

by:LindaOKSTATE
ID: 37788767
Jeff the =CurrentUser() returned "admin".  Scott, not sure if I want to go into that much programming,  I was hoping for an easy fix like the =CurrentUser().

I'll get back to this after I try a few more things.

Thanks,
LindaOKState
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 37788819
Are you logging into a business network?  If so, the CNAME should be the person's unique login "name".

If this doesn't work for you (as suggested by your last comment) then you may have to create a "login routine" (more programming).

There is no way for Access to determine who "runs" a report or query.  You're gonna' have to deal with it per code and tables.

Scott C
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 37788831
PS.  I've written many custom "login" procedures.  They all involve tables of users, user types (Admin, Read-Only, etc.) and passwords, a login form (includes code to change password), forces users to "log in", the user table must be available to "app admins", etc.   Yeah... lots of code.....    

I can help by pasting pieces of this type of procedure... but it is (somewhat) large.

Sorry..... :-)

Scott C
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 37793403
CurrentUser will work -- but it may yield "Admin".  And of course there is no way of telling whether another person sat down at the computer and printed the report.
0
 
LVL 31

Assisted Solution

by:Helen Feddema
Helen Feddema earned 33 total points
ID: 37793404
One way to do this might be to put a combo box on the main menu, for selecting user names.  You would have to select one in order to enable a button for printing a report.
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 37793409
New Style Main MenuSee my New Style Main Menu (Access Archon #212).  You could use the same technique I use for selecting a Customer or Order ID for filtering a report, except without the filtering.

http://www.helenfeddema.com/Files/accarch212.zip
New Style Main Menu
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 37793412
Sorry, didn't mean to post the image twice.
0
 

Author Closing Comment

by:LindaOKSTATE
ID: 37829919
Thank you all, I have been told there are functions in my database that should pick up a global User ID but I probably will just not use this data on the report.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

635 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