CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> ASP

 Populating Form field with variable

Print topic Send  topic

Author Message
Rich
Posted: 05/12/2004, 4:28 AM

This seems like it should be easy.

On form 1 i add a record. After the insert i retrieve the last identity added and put that value in a variable.

Form 2 pops up. The first field in that form expects the identity (the value i have in my variable).

How can i populate that form field automaticaly with my variable value? I'm not looking to do an insert yet because i still need to fill in the rest of the form.

Thanks!
peterr


Posts: 5971
Posted: 05/12/2004, 11:03 AM

The "Multi-Step User Registration" example in CCS Example Pack demonstrates how to do this. It is also live at http://examples.codecharge.com/ExamplePack/MultiStepReg...gistration1.php
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
rrabin

Posts: 2
Posted: 05/12/2004, 12:01 PM

I'm not necessarily looking to save the information and move on, instead - i need to populate one field in the form on page 2.

Example:
form one has field "id". After insert, i get the value of "id" and put it in variable "var_id".

I hit submit and brings me to form 2

The first field in form 2 is "id" and needs to contain the value from my "var_id". I can't seem to find a way to show on the page this value.
View profile  Send private message
peterr


Posts: 5971
Posted: 05/12/2004, 12:09 PM

I suggest using the "Retrieve Value For Control" Action (http://docs.codecharge.com/studio/html/Actions/Server/Retrieve%20Value%20For%20Control.html) in the Before Shown event of that field in form 2.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Tony Do
Posted: 05/12/2004, 5:54 PM

Hi Rich
If I understand you correctly that you insert a record in form1 in page1
then you assign the identity value in a variable in page1 then page1
redirect you to page2 which has form2 and then a field in form2 need to have
a default value to that identity value.

If it is then you have 2 ways to do this

1) Instead of assign the identity value to a variable in form 1, you can
assign it value to a session variable and then in the before show event of
your field in form 2 have this code
EventCaller.value = Session("LastIdentity")
'clear your Session variable
Session("LastIdentity") = empty

2)In the after execute insert event get your Identity value and assign it
to a varaible called yourvariable and then have the follwing code
Reponse.clear
Response.redirect "page2.asp?ID=" & yourvariable
rich
Posted: 05/17/2004, 8:09 AM

Tony,

Thanks for the info - you are exactly right - that's what i'm trying to do. Unfortunately, being very new to this, i'm still running into issues.

If you can, is there a way you can "dumb it down" for me? would it be too much to ask if you can expand a little on the exact steps i would have to take?

Thanks again

Quote Tony Do:
Hi Rich
If I understand you correctly that you insert a record in form1 in page1
then you assign the identity value in a variable in page1 then page1
redirect you to page2 which has form2 and then a field in form2 need to have
a default value to that identity value.

If it is then you have 2 ways to do this

1) Instead of assign the identity value to a variable in form 1, you can
assign it value to a session variable and then in the before show event of
your field in form 2 have this code
EventCaller.value = Session("LastIdentity")
'clear your Session variable
Session("LastIdentity") = empty

2)In the after execute insert event get your Identity value and assign it
to a varaible called yourvariable and then have the follwing code
Reponse.clear
Response.redirect "page2.asp?ID=" & yourvariable
Tony Do
Posted: 05/17/2004, 8:49 PM


Hi Rich

Assume
Your Form name is: Payment

The Connection Name is: Connection1


Then in the After execute insert Event of your form

<Code>
If DBConnection1.Errors.Count = 0 Then
Dim SQLIdentity, IdentityVariable, Recordset1
SQLIdentity="SELECT @@IDENTITY as id"
Set RecordSet1 = DBConnection1.Execute(SQLIdentity)
IdentityVariable=Recordset1("id")
Response.end
Response.Redirect "secondpage.asp?identityvalue=" & IdentityVariable
End If

</Code>

Now in the secondpage.asp,
Reccord Form name is : Customers
Control name (that you want to populate with the identity value from the
previous page) is PaymentID

To populate the identity value into the Control name PaymentID
In the before show event of your Customers record form

<Code>
EventCaller.PaymentID.Value = Request.QueryString("identityvalue")
</Code>

Rich
Posted: 05/18/2004, 5:18 AM

Tony,

thanks again for your help - it's starting to make sense. I followed your instructions and now i guess i'm having an issue with the redirect?

form1 name is test1_maint. i put in the custom code for AfterExecuteInsert
form2 name is secondpage . i put in the custom code for BeforeShow

When i hit the "add" button on form 1 it redirects me to: test_maint.asp?ccsForm=test1 ... and it's blank - shouldn't it go to secondpage?

The only other thing i changed...under the test1_maint page, i have the "Return Page" set to secondpage.ccp... is that correct?

I really appreciate you helping me out with this - you are saving me!

Rich
Tony Do
Posted: 05/18/2004, 4:37 PM

What is your custom codes in the AfterExecuteInsert?

If your Custom code does have this block
<code>
If dbConnection1.Erros.count = 0 Then
....
Response.redirect "secondpage.asp?...."
End If
</code>

The redirect only redirect to "secondpage.asp" if there is no errors of
inserting the records


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.