This topic is locked

BeforeEdit Event on Events editor

11/28/2008 5:09:05 AM
ASPRunnerPro General questions
Z
zion4ever author

Hello all,
I cannot seem to figure this one out:

I have an ASPrunner project with and edit page.
Now I have located the filed names on that edit page by opening the html source of the rendered page in my browser. Let's say I have a field, which is a dropdown date field with the name attribute "yearvalue_fYear"
Now I would like to check the value of that field before it may be edited.
Dim fYear

fYear = dict(""yearvalue_fYear")
If fYear = "2008"Then

'Do something

BeforeEdit = True

Else

'Do nothing

BeforeEdit=False

End If
The above code gives me a blank variable. Am i missing something here?
TIA
Hans

Z
zion4ever author 11/28/2008

Btw i'm using ASPrunner 5.1

J
Jane 11/28/2008

Hi,
entered values are stored in the dict collection, I.e. dict("FieldName1"), dict("FieldName2"), etc.

Here is a sample:

fYear = Year(dict("FieldName"))

Z
zion4ever author 11/28/2008

Thanks for the reply Jane.

I actually sorted it by referencing the index directly:
I.e.

Spec = dict(dkeys(1))
That worked for me. However I still have a question I hope you are able to help me with.

The following code is in the Before Edit Update event:
[codebox]strSQLExists = "SELECT `Gereserveerd door` from tblReserveringen WHERE ID='" & Session("nID") & "';"

set rsExists = CreateObject("ADODB.Recordset")

rsExists.Open strSQLExists, dbConnection
If rsExists.eof Then

'Record not found

isOwner = False

Else

'Record found

if rsExists("Gereserveerd door") <> GereserveerdDoor Then

isOwner = False

else

isOwner = True

end if

End if
rsExists.Close : set rsExists = Nothing
if isOwner = False Then
strSQLExists = "SELECT * from tblReserveringen WHERE ((date('" & BeginDatum & "') BETWEEN tblReserveringen.`Gereserveerd vanaf` AND tblReserveringen.`Gereserveerd tot` OR date('" & EindDatum & "') BETWEEN tblReserveringen.`Gereserveerd vanaf` AND tblReserveringen.`Gereserveerd tot`) AND tblReserveringen.specificatie='" & Spec & "' AND (tblReserveringen.Status='Gereserveerd' OR tblReserveringen.Status='Geannuleerd') AND Object='" & UitleenObj & "');"

set rsExists = CreateObject("ADODB.Recordset")

rsExists.Open strSQLExists, dbConnection
If rsExists.EOF Then

'Record not found, dus item is beschikbaar!

Available = True

else

Available = False

end if
rsExists.Close : set rsExists = Nothing
else

Available = True

end if
' set BeforeEdit to True if you like to proceed with editing this record

' set it to False otherwise

if Available = False then

BeforeEdit = False

Response.Write("<script language=""javascript"">alert('" & UitleenObj & " voor periode " & BeginDatum & " t/m " & EindDatum & " is reeds bezet!');self.location='tblreserveringen_list.asp?a=return'</script>")

else

If Status = "Opgehaald" Then

ContinueSql = True

end if

end if
if ContinueSql = True Then

'Update tblUitleen; set tbluitleen.status = "Uitgeleend" en overige uitleen parameters

strSQL = "UPDATE tblUitleen SET Specificatie='" & Spec & "', `Object`='" & UitleenObj & "', `Status` = '" & Status & "', `Datum uitgeleend` ='" & Ophaaldatum & "', `Datum terug` = '" & EindDatum & "', `Uitgeleend aan` = '" & GereserveerdDoor & "', Opmerkingen = '" & Opmerkingen & "', Status = 'Uitgeleend' WHERE Object='" & UitleenObj & "';"

set rs = CreateObject("ADODB.Recordset")

rs.Open strSQL, dbConnection

End If
'Update tblReserveringen

BeforeEdit = True
Response.Write("<script language=""javascript"">alert('Record is succesvol gewijzigd!');self.location='tblreserveringen_list.asp?a=return'</script>")[/codebox]
This code works works, however it updates the 2nd table (tblUitleen), but it fails to update the table (tblReserveringen) afterwards, although BeforeEdit = True

When I remove the equation If Status = "Opgehaald" code block, the BeforeEdit = True is properly executed and the tblReserveringen is updated fine.
Can't the BeforeEdit function be called after updating another table?
Regards
Hans

J
Jane 12/1/2008

Hans,
try to use this code instead:

...

If Status = "Opgehaald" Then

ContinueSql = True

else

ContinueSql = False

end if

...

Z
zion4ever author 12/2/2008

Hi Jane,
Thnx for the reply.

Sorry to report that didn.'t work as well.
I rewrote some of the code, but just can't figure out what to do anymore. Plz help me out.

It seems that the custom SQL code (update another database table) in the BEFORE UPDATE function is properly executed, but the table itself is not.
If I remove the part that updates another table from the BEFORE UPDATE event (function) then the table that is being edited itself (tblReserveringen ) is properly updated.
I really don't understand.
TIA
Hans

J
Jane 12/2/2008

Hans,
to update another table use following code:

if ContinueSql = True Then

'Update tblUitleen; set tbluitleen.status = "Uitgeleend" en overige uitleen parameters

strSQL = "UPDATE tblUitleen SET Specificatie='" & Spec & "', `Object`='" & UitleenObj & "', `Status` = '" & Status & "', `Datum uitgeleend` ='" & Ophaaldatum & "', `Datum terug` = '" & EindDatum & "', `Uitgeleend aan` = '" & GereserveerdDoor & "', Opmerkingen = '" & Opmerkingen & "', Status = 'Uitgeleend' WHERE Object='" & UitleenObj & "';"

dbConnection.Execute strSQL

End If


If it doesn't help publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

Z
zion4ever author 12/3/2008

Jane,
Thank you so much for helping me. It still didnt work. However, I found a workaround:

I did a response.redirect to a page called Process.asp. This page was built manually with a text editor. In there I insert the database values in the other table based on a querystring that is sent from the Before Update function.
But help!!!!

Everything worked fine, I made no modifications, but suddenly I get this message:

End tag not found:{END mastertable_block}
Plz can you advise what is happening?

I need to deliver this intranet project by Friday and I have no clue what is wrong.

J
Jane 12/3/2008

Hi,
End tag not found error means that you have removed {END mastertable_block} on the Visual Editor tab.

Here is the correct code:

{BEGIN mastertable_block}

<DIV id="mastertable_block{$id}">{$showmasterfile}

<A class=toplinks {$backtomasterlink_attrs}><B>{mlang_message BACK_TO_MASTER}</B></A>

<BR>

</DIV>

{END mastertable_block}

Z
zion4ever author 12/3/2008

Thank you for the swift reply Jane,
I did as you said and the error disappeared.

However, now when I click on the link next to a dropdown (database lookup wizard) I get a popup window that is a copy of the edit page.

If I close that window the edit/add pages form elements are disappeared and all that is left is the table and it's backcolor.
What I want is the little popup window with one text field and an ADD button that enables me to add a new value to the list on the fly.
Any thoughts?

J
Jane 12/3/2008

Hi,
It's difficult to tell you what's happening without seeing actual files.

We've fixed some similar bugs in the previous version.
I recommend you to publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.