Solved

print name or id of person running access report

Posted on 2012-03-30
14
338 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
  • 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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now