|
|
Sometimes you need to present different data to different groups
of users. Let's say you run a classified ads board and needs to
display last seven days data to regular users while admin should be
able to see all adds.
For this purpose use Before
SQL Query event of the List page.
Note: Change
the values listed in red to
match your specific needs.
1. For MS SQL Server database:
|
if Session("UserID")<>"admin" then
strWhereClause = whereAdd(strWhereClause, _
"DATEDIFF(day,GETDATE(),DateColumn)<=7")
end if
|
2. For MySQL database:
|
if Session("UserID")<>"admin" then
strWhereClause = whereAdd(strWhereClause, _
"DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= DateColumn")
end if
|
3. For MS Access database:
|
if Session("UserID")<>"admin" then
strWhereClause = whereAdd(strWhereClause, _
"DateDiff('d',Now(),DateColumn)<=7")
end if
|
whereAdd() function adds
new AND condition to
WHERE clause. More
info on Data Access Layer functions.
|