This topic is locked

Before Display

11/15/2007 7:37:48 PM
ASPRunnerPro General questions
M
Michael7 author

Hi,

Trying to use before display event to add 1 to views. similar to this forum.

this is done when accessing a detail page from the master page so when clicking onto the detail page i execute the following
// List page: Before display

Sub BeforeShowList(smarty,templatefile)
'** UPDATE a record in another table ****

set rstmp = Server.CreateObject("ADODB.Recordset")

rstmp.Open "select Views from [Communications] where ID=" & key, dbConnection
strSQLUpdate = "UPDATE Communications SET Views="&rstmp("Views")+1&" Where ID=[color=#ff0000]'"&Session(strCommunications & "_MasterKey1")&"'"

dbConnection.Execute strSQLUpdate
rstmp.Close

set rstmp = nothing

End Sub ' BeforeShowList
Views is a Number field in an Access DB at the moment if i manuall enter an ID = 27 where the red is it will work. but if i try to use the above to get the id it wont.

The error says it is not finding an ID.
Thanks for you help

Regards

Michael

V5 - 326
[/color]

D
dlangham 11/16/2007

Hi,
Try using Session(strTableName & "_masterkey1") instead of Session(strCommunications & "_MasterKey1") and see if this works.

M
Michael7 author 11/16/2007

Cheers. have changed to strTableName and dropped the last &"'" off and all is now working
thanks

Michael