Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

increment a number field each time a record is viewed

Status
Not open for further replies.

sfunk

Technical User
Jan 22, 2002
107
0
0
US
Hello,

Is there a way in Access to build a record view counter of sorts.

I am online and watching this closely so I can respond to questions as well as test suggestions quickly.

I am using an Access database in an ASP application. Rather than build an update function in ASP that increments a number field everytime a record is viewed I would like to find a way to build a formula in Access with the default value or some other means in Access.

Each time a row in a table is accessed I want to increment a column in the same table by 1. Is there a way to do this in Access?

Thank you,
stve
 
If you are doing it from an Access form there is because the Access Form itself will respond to the On Current event and you can put code into that event to increment a value in a control.

So extending that thought process ..

When you open your recordset and have populated your Web Page with all the other values, then just increment the value in the counter field, update the recordset and then output the incremented value to the page.

G LS
 
The reliable way is to use DAO to open the table, find the record in the table, increment the field, update the record and close the table. You would have to requery on completion of the task.

The sub would be about 10 lines of code, which you would use in the after update event of control on the form. You'd have to pass the value of the key field to the sub.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top