CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 next record on submit

Print topic Send  topic

Author Message
flipandboef


Posts: 107
Posted: 12/29/2008, 8:07 AM

This must be simple, but cannot find the solution....

I have a lot of records and they all have to be edited.
What I like to accomplish is to edit a record (not add!) and when the changes are made, it returns the next record.
Standard my records are sorted by ProdId (Desc), that is the Autonum / Prim Key in the table.
So if I edit ProdID 321, edit it and hit submit, I like to go to ProdId 320

Anyone any ideas on this? Pretty sure it's a simple solution ;-)


(ASP, CCS 3.2, Access DB)
View profile  Send private message
flipandboef


Posts: 107
Posted: 01/23/2009, 11:45 AM

No one a solution to this easy (I think) "problem" ? :-(
View profile  Send private message
Chris__T


Posts: 339
Posted: 01/23/2009, 2:00 PM

this is just pulling stuff from my head but couldn't you do this?

1) when you click the button, a temp variable pulls the ProdId from the record being saved ( CCGetFromGet() ? )

2) increment the value of this temp variable...... temp = temp +1 or something like that

3) then do a redirect with the page going to http://yoursite/yourfolder/recordpage.asp?ProdId=temp
View profile  Send private message
flipandboef


Posts: 107
Posted: 02/18/2009, 12:01 PM

Thanks!
This worked out almost exactly as I needed it :-)

I used this code:
  
Dim X  
X = ( CCGetFromGet("ProdId",0))  
X = X -1  
Redirect = "mypage.asp?ProdID="&X  

Only 1 more issue with this...
I have a field Validated (true/false)...
How can I implement a Where statement in this, so it will check that Validated = false?

So basically trying to accomplish:
that it does X-1, checks if that record is Validated False, If not, it does again X-1 until it finds the record where Validated=false.

Example:
I edit ProdId 123 and press Submit.
It goes to ProdId 122 and sees that Validated = True
Then it tries ProdId 121, checks it again. Also false!
Goes to ProdId 120 and there it's True so opens that record.

Is this possible / easy to implement?
View profile  Send private message
dataobjx


Posts: 181
Posted: 02/21/2009, 6:01 AM

Here's an alternative method of logic using a 'type' of recursion..
I got a little confused about whether isValidated needs to be true or false to perform the desired action (the redirect) so watch out for that.
Also, I did this in notepad so the logic is right, but the code may need tweaking - but this should provide you with a head start.

The benefit of using the recursive routine is related to deleted rows. Using this technique, once called will continue to call itself until the criterion has been met and then perform the redirect or whatever.

Sub SomeSubroutine
Dim X
X = ( CCGetFromGet("ProdId",0))
X = X -1
CheckValidationAndRedirect(X)
End Sub

Sub CheckValidationAndRedirect(X)
'Perform a DB Query to verify that record id 'X' exists... and you may as well pull in the
'validated field at the same time
Dim SQL
Dim Recordset
Dim isValidated

If X > 0 Then
SQL = "Select ProdID, Validated from ATable Where ProdID = " & X
Set Recordset = DBConnection1.Execute(SQL)
If Not Recordset.EOF Then
isValidated = CCGetValue(RecordSet, "Validated")
If isValidated = "True" Then
Redirect = "mypage.asp?ProdID="&X
Else
'isValidated
'Increment X and recursively call the function
X = X -1
CheckValidationAndRedirect(X)
End If
Else
'ProdID "X" does not exist (deleted)..Increment X and recursively call the function
X = X -1
CheckValidationAndRedirect(X)
End If
End If
End Sub
_________________
www.DataObjx.net
www.mydigitalapps.com
View profile  Send private message
flipandboef


Posts: 107
Posted: 02/23/2009, 8:06 AM

WOW,
Thanks so much for this... I (almost) completely see what you're doing here and am sure I will be able to make this work in my situation...

To answer your question: Validated needed to be False....
I also changed the pagename and of cos the field name in your code...

However... As I am not (better said: far from O:)) an ASP programmer, I'm stuck at one part:
the connection.....

In your beautiful given code, I'm struggling with this line:
Set Recordset = DBConnection1.Execute(SQL)

Hopefully you can shine some light on that one?
Again thank you so much already!

View profile  Send private message
dataobjx


Posts: 181
Posted: 02/23/2009, 6:44 PM

OK, to derive the recordset - you should look in the CCS Help file.

F1 help... then go to Examples and Techniques --> programming --> Working with databases --> Retrieve Multiple Field Values from a Database

The name of your connection may be different from the one provided in the example.

So... say you have a grid or recordset on the form that you're working with. If you open the code 'tab' and look at around line 33 or so you should see a line with your connection name.

E.g.,

' Connections
Dim DBDataObjx

Change DBConnection1 to DBDataObjx for example.

Hope this helps.
_________________
www.DataObjx.net
www.mydigitalapps.com
View profile  Send private message
flipandboef


Posts: 107
Posted: 02/24/2009, 8:12 AM

I can not express how much I appreciate your help and great explanations!

Your code seems to work fine, after I changed the connection (as far as I tested it yet)...

I had to however change one line:
From: If isValidated = "True" Then
To: If NOT isValidated = "True" Then

I tried using: [If isValidated = "False" Then]
and: [If isValidated = "" Then], but then I got the next error:
--------------
Active Server Pages error 'ASP 0107'
Data size too large
/mypage.asp
Size of data being sent in the request is over the allowed limit.
--------------

Not sure why that happens, however... As mentioned it seems to work.. I will do a few more tests to see if all works great.
Again: Thank you so much for all your help and explanations and I will post to let you know if all is great now.
View profile  Send private message
dataobjx


Posts: 181
Posted: 02/24/2009, 1:59 PM

Not a problem, glad to have been of assistance.

Let me know how it goes!

Best

M
_________________
www.DataObjx.net
www.mydigitalapps.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.