I'm trying to determine the useage of varioius reports I have. I need
the following to occur when a report is opened, get the name of the
report, datetime, username.
I created a tblLog w/reportname, reportdate and theuser.
This is the module I have for capturing the username.
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.d ll" Alias _
"GetUserNam eA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName( strUserName, lngLen)
If ( lngX 0 ) Then
fOSUserName = Left$(strUserNa me, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
How would I use this, can it be done on the onopen event of all
reports? How would I use above and insert it into the tblLog
Module for inserting reportname, reportdate into the table
Function ReportUsage(InR eportName As String)
On Error GoTo Error1
Dim db As DATABASE
Dim rs As Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordse t("tblReportUsa ge") 'name of your table
rs.AddNew
rs("ReportName" ) = InReportName
rs("ReportDate" ) = Now 'Never call a field "Date" !!
rs.Update
Exit1:
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
Exit Sub
Error1:
MsgBox Err.Number & "; " & Err.Description
Resume Exit1
End Function 3 2417
you have the log table already, so just create an Append query to add a
record to the table. run the Append query in the same code (or macro) that
opens the report. an example of the SQL statement follows:
CurrentDb.Execu te "INSERT INTO tblLog ( rptName, " _
& "rptDate, rptUser ) SELECT '" & strReportName _
& "', #" & Date & "#, '" & fOSUserName & "'", _
dbFailOnError
hth
"T" <te****@wideope nwest.comwrote in message
news:11******** **************@ d57g2000hsg.goo glegroups.com.. .
I'm trying to determine the useage of varioius reports I have. I need
the following to occur when a report is opened, get the name of the
report, datetime, username.
I created a tblLog w/reportname, reportdate and theuser.
This is the module I have for capturing the username.
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.d ll" Alias _
"GetUserNam eA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName( strUserName, lngLen)
If ( lngX 0 ) Then
fOSUserName = Left$(strUserNa me, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
How would I use this, can it be done on the onopen event of all
reports? How would I use above and insert it into the tblLog
Module for inserting reportname, reportdate into the table
Function ReportUsage(InR eportName As String)
On Error GoTo Error1
Dim db As DATABASE
Dim rs As Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordse t("tblReportUsa ge") 'name of your table
rs.AddNew
rs("ReportName" ) = InReportName
rs("ReportDate" ) = Now 'Never call a field "Date" !!
rs.Update
Exit1:
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
Exit Sub
Error1:
MsgBox Err.Number & "; " & Err.Description
Resume Exit1
End Function
Yup ... you've got it!
Here it is with some very minor revisions:
=============== =============== =============== =======
Module for inserting reportname, reportdate, (AND UserName) into the table.
Function ReportUsage(InR eportName As String)
On Error GoTo Error1
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordse t("tblLog", dbOpenDynaset) 'name of your table is
"tblLog" you said, correct?
With rs
.AddNew
!ReportName = InReportName 'Calling this function from ANY report will
supply the report name
!ReportDate = Now 'Never call a field "Date" !!
!TheUser = fOSUserName
.Update
.Close
End With
Exit1:
db.Close
Set rs = Nothing
Set db = Nothing
Exit Sub
Error1:
MsgBox Err.Number & "; " & Err.Description
Resume Exit1
End Function
=============== =============== =========
All you need to do is to put that function in a module in the DB window, so
that it is available globally.
I'd stick your function in the same module as Dev's API.
Put this in each report's code module
=============== =============== =========
Private Sub Report_Open(Can cel As Integer)
DoCmd.Maximize
ReportUsage (Me.Name) ' The report name will be passed to the function and
inserted in your log table
End Sub
--
--
HTH,
Don
=============== ==============
E-Mail (if you must) My*****@Telus.n et
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)
I'm an Access97 user, so all posted code samples are also Access97- based
unless otherwise noted.
=============== =============== =============== =============== ==============
"T" <te****@wideope nwest.comwrote in message
news:11******** **************@ d57g2000hsg.goo glegroups.com.. .
I'm trying to determine the useage of varioius reports I have. I need
the following to occur when a report is opened, get the name of the
report, datetime, username.
I created a tblLog w/reportname, reportdate and theuser.
This is the module I have for capturing the username.
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.d ll" Alias _
"GetUserNam eA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName( strUserName, lngLen)
If ( lngX 0 ) Then
fOSUserName = Left$(strUserNa me, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
How would I use this, can it be done on the onopen event of all
reports? How would I use above and insert it into the tblLog
Module for inserting reportname, reportdate, UserName into the table
Function ReportUsage(InR eportName As String)
On Error GoTo Error1
Dim db As DATABASE
Dim rs As Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordse t("tblReportUsa ge") 'name of your table
rs.AddNew
rs("ReportName" ) = InReportName
rs("ReportDate" ) = Now 'Never call a field "Date" !!
rs.Update
Exit1:
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
Exit Sub
Error1:
MsgBox Err.Number & "; " & Err.Description
Resume Exit1
End Function
For what it's worth, you may also want to add a (shudder) Autonumber
field to that table. This will allow the table to be sorted in the
order that the "events" are written to the table in. I say "Shudder"
as I've had a few problems with autonumber fields over the years, and
have learned not to (totally) trust them. Your mileage may (and
probably will!) vary, however it's really up to you. (Other here may
report ever seeing such problems, but a search of this newsgroup will
show a few.)
Personally, I have a Public module-level function I use for this task,
which means that I can just call it from anywhere in my DB to stuff
something into the log, and another function that exports it whenever
I want to export (and possibly clear) the table.
On Apr 14, 2:03 pm, "T" <tei...@wideope nwest.comwrote:
I'm trying to determine the useage of varioius reports I have. I need
the following to occur when a report is opened, get the name of the
report, datetime, username.
I created a tblLog w/reportname, reportdate and theuser.
This is the module I have for capturing the username.
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.d ll" Alias _
"GetUserNam eA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName( strUserName, lngLen)
If ( lngX 0 ) Then
fOSUserName = Left$(strUserNa me, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
How would I use this, can it be done on the onopen event of all
reports? How would I use above and insert it into the tblLog
Module for inserting reportname, reportdate into the table
Function ReportUsage(InR eportName As String)
On Error GoTo Error1
Dim db As DATABASE
Dim rs As Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordse t("tblReportUsa ge") 'name of your table
rs.AddNew
rs("ReportName" ) = InReportName
rs("ReportDate" ) = Now 'Never call a field "Date" !!
rs.Update
Exit1:
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
Exit Sub
Error1:
MsgBox Err.Number & "; " & Err.Description
Resume Exit1
End Function
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: puunda |
last post by:
Hi,
Hope I've posted to the right groups.
I'm trying create a Crystal Report for the first time using C# (novice
at that as well). The CR I can handel. What I want to do is to have a
whole bunch of fields in my application (winforms) which the user can
select to include in the report or not.
I believe I can use the CR Engine to change the report at runtime. Here
|
by: Simon Bailey |
last post by:
How do you created a query in VB?
I have a button on a form that signifies a certain computer in a
computer suite. On clicking on this button i would like to create a
query searching for all details invovling that computer, for the user
to then view.
Any ideas on some code?
Many thanks for any help.
|
by: James |
last post by:
I am creating a system whereby equipment is inspected. Data is
inputted into an inspection form. However, any equipment that is not
satisfactory needs to have spare parts ordered for that piece of
equipment from a list of parts. I kind of need a form which lists
parts and then check boxes next to a part can be created so the user
can select which parts are needed and then a button is clicked which
sends these parts to a report. I am not...
|
by: longtim |
last post by:
I have been having endless difficulty creating reports/queries that
set any relevent parameters from controls in forms.
I am creating an application under access 2003 but will target access
2000. The access file is in access 2000 format.
I have a form that will hold the relevent parameters for the
query/report that reports the statistics for all job records that
match a certain criteria. These are:
- A Customer Name.
|
by: enak |
last post by:
I have found some code that shows how to convert an html
form to Word. The message said to simply put the following
in the Page_load:
Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")
Now all I should have to do is create the page just like I
would if I were going to display it in the browser.
| |
by: rreitsma |
last post by:
I want to create a form that will allow the user to select from a list of
available reports and based on a filter limit the records displayed in the
report. I have figured out how to access the reports collection to populate
a list box containing the report names. The filter I currently have lists
some key fields that I think the user may want to filter on. A WHERE string
is constructed based on the feilds that the user inputs values into....
|
by: mmueller |
last post by:
I am new to reporting services 2005 (reporting in Access for years and older versions of Reporting Services from time to time) and this is probably a dumb question... but I have no internal resources since I am the first to use it so... here you go:
I have a report I am trying to recreate, the old one is in a PowerBuilder app and the author is no longer with company. The majority of the report is straightforward, but I am really hung up on...
|
by: Andy |
last post by:
Hi guys
I having a problem creating a report in Access 2003 project talking to
a SQL database through and ODBC connect.
After hours of trying things from Access Help, MSDN and Google I still
can't get it working.
I have a query defined (view) and want the end user to put in a start
date and end date to filter a report.
|
by: sklett |
last post by:
I've developed an ERP application that we use internally and works quite
well. I receiving more and more requests from users to print various
transactions, order forms, search results, etc. I haven't decided what the
best way to do this is because I don't have much experience with generating
printable forms.
Early on I knew one of my modules would need to print a clear report so I
used the open source SharpPDF library to generate the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |