This topic is locked

Redirect based on Field Value

11/12/2010 4:41:17 PM
ASPRunnerPro General questions
C
cawright author

Is there a way to redirect a user who has chosen to edit a record, to the view page based on the value in the record they would like to edit. For example, I have a list of reports that employees create and the status field is marked as "New" when it is created. Once they have finalized the data and changed the status field to "submitted" I don't want them to be able to edit the record, but I would like the user to be able to view the record. So, If the user selects a report to edit but the status field is "submitted" I want to redirect to the view page instead of the edit page. In what event would I put the redirect code and so help with the code would be appreciated as well.

Sergey Kornilov admin 11/15/2010

Just a basic idea of how you can make it work. Put this code to 'Edit page: BeforeProcess event'. Replace names in bold with actual field and table names.

sql = "select statusfrom TableNamewhere KeyColumn=" & Request.QueryString("editid1")

set rs = CustomQuery(sql)

if rs("Status")="submitted" then

response.redirect "tablename_view.asp?editid1=" & Request.QueryString("editid1")

end if