count number of times record is viewed...

  • Thread starter Thread starter Mike Lindegarde
  • Start date Start date
M

Mike Lindegarde

Guest
What I would like to do is have a field in a given record increment itself every time that record is selected. For example, say you have a table that stores items in the inventory: each item has a times_search_for_field.

Now, lets say a user runs a search which results in the following SQL:

SELECT * FROM Inventory WHERE experation_date=Today();

Now I want to have every record returned by that SQL statement increment it's times_search_for_field incremented by one. I'm just looking for the most efficiant way to do this.

I know I chould just have my asp .net code loop through the results and call an SQL UPDATE statement for each record, but it seems there should be a more efficient way of doing this.

Mike.
 
Hello:

You can place the the following line of code in the OnCurrent event of your form and it will Increment a field named "Viewed".
'
Viewed = Viewed + 1
'
You can also place the below code in the AfterUpdate event of a combobox named cboFindRecord. It searches by the key field named EmployeeID of a table named tblEmployees.
Regards
Mark

'
Private Sub cboFindRecord_AfterUpdate()
'Find the record that matches the control.
Dim rs As Object
'
Set rs = Me.Recordset.Clone
rs.FindFirst "[EmployeeID] = " & Str(Nz(Me![cboFindRecord], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
'Increment the Viewed field by one
Viewed = Viewed + 1
End Sub
 

Users who are viewing this thread

Back
Top Bottom