How do I record report views?

G

Greg Blair

Ted,

You need to open a recordset based on the table you're writing to. Then add
a new record and then update the database.

I'm using DAO for my data access. Assuming that you have created the table
and the FE is linked to the BE table:

Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("SELECT * FROM reportlog")
' Get ready to create a new record in the reportlog table.
rst.AddNew
' I made up some plausible column names for the reportlog table.
rst![User] = CurrentUser
rst![Date] = Now
rst!
= Me.RecordSource
' Now, write the record to the actual table.
rst.Update
' Clean up.
Set rst = Nothing


That should be close to the needed code to accomplish this task.

Greg
 
T

Ted

Hello All,

I want to be able to record when a user "views a report" - the system holds
the variables of [currentuser]; [now()] and [recordsource] which I believe
would be sufficient for my purposes...

How do I take those variables when a report is viewed, and write them to a
table (named 'reportlog') ?

I can view the variables on the report (by creating 'textboxes'), but am not
sure how to then take this data & write it to a table...

My database is split into FE/BE, the reports being in the FE, and the table
in the BE.

Can this be done?


Your advice would be appreciated!

Many thanks
 
M

Mingqing Cheng [MSFT]

Hi Ted,

I noticed Greg has give you a great answer for your questions. I wanted to
post a quick note to see if you would like additional assistance or
information regarding this particular issue. We appreciate your patience
and look forward to hearing from you!


Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are here to be of assistance!


Sincerely yours,

Mingqing Cheng
Microsoft Developer Community Support
 
T

Ted

Thank you both very much for your, help, advice and offers of assistance.

I find it very gratifying that there are such caring and helpful people,
like yourselves, on the net.
What a fabulous tool and resource we have access to!!
Gone are my days of going down to the local library, to seek the information
I need to satisfy my curiosity !! ;)

I wish to share with you the code I eventually added to my database.

My code has been attached to the 'On Open' property of each 'report'.

Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Dim rst1 As New ADODB.Recordset
Dim sql1 As String
sql1 = "select [Userview],[Dateview],[Reportview] from [Reportlog]"
rst1.Open sql1, cnn, adOpenKeyset, adLockOptimistic
With rst1
..addnew
![Userview] = currentuser()
![Dateview] = Now()
![Reportview] = me.recordsource
..update
End With
rst1.Close
Set cnn = Nothing


Once again, many thanks!
 
M

Mingqing Cheng [MSFT]

Hi Ted,

It's great to hear that you have resolved it successfully!

Thanks for sharing it in the Newsgroup, if you encounter any questions or
concerns on Access, please feel free to post here. We are always here to be
of assistance!

Thanks for you kindest sharing to make us updated of of resolution again.


Sincerely yours,

Mingqing Cheng
Microsoft Developer Community Support
 
Top