copy text field data from one form page to another!

Posted on 2006-05-17
Last Modified: 2012-06-27
Hi All,

This is Sam. This time my question is going to be the most simple one I'd ever asked.

What command I should use to copy the text field "text1" data in the page "form1" to another text field "text2" in the page "form2"?


This is definitely wrong and an error message displays "text2 does not exist."

Question by:sami_hung
    LVL 7

    Expert Comment

    Hi Sam, it looks like you're developing a website in ASP?

    If so, the problem is that you can't directly copy data from one webpage to another

    The best way to do this would be to set up a 'form' using a <form> tag and a submit button within the <Form> </Form> tags.

    The Submit button takes you to the 'Form2' page and you can interpret the data from your first page there by referencing the objects on the form on your previous page
    LVL 7

    Expert Comment

    I should also have added, you need to use the request object to get your info from the second page... e.g..

    a = Request("inputfield")

    and your form tag should look like this

    <form METHOD="post" ACTION="page2.asp" id="frmCreate" name="frmCreate">


    Author Comment

    Hi Clever Bob,

    Well one thing I have to make myself more clear is that I'm not developing a web page in ASP or something, but just using the old version of Visual Foxpro (V6.0). I should write in more details of my question, or actually a very simple question:

    I now generated two forms ("form1.scx" and "form2.scx") and "form1" contains text field (text1) and "form2" contains text field (text2). I'm writing a search function in form2.scx in order to copy data from "text2" to "text1".

    I had tried this way: "thisform.text1.value=thisform.text2.value"
    As I run this command it generates an error message "text1 does not exist." (because text1 is not in "form2"). In other words I cannot use "thisform.text1.value" in search function.

    Please help,
    LVL 8

    Expert Comment

    have u tried using following?
    LVL 3

    Expert Comment

    Hi Sam

    It will not work.
    Since thisform is only the current form.

    Tell me do you want the value of Form2 ,text2 to have the same value as form1 text1  at run time ?
    which means form1 is also running and form2 is also running ?

    Case -1
    If you are calling form2 from form1 , you can do the fo,llowing

    do form form2 with thisform.text1.value

    In Init of Form2

    lPAramter cFrm1txt1val
    thisform.text2.value = cFrmtxt1val

    This will put form1's text1's value in form2 text2 (i noticed it is reverse of what you asked...pls swap the forms accordingly :-))


    Case 2
    If you are not calling the second form from first form
    and it is an independent form ...and both can be selected from the menu and run simulataneously

    in Form1

    If vartype("Form2") = "O"
           thisform.text1.value = form2.text2.value    



    Author Comment

    Hi archana,

    Thanks for your idea. I think it works.
    But what if more than 1 text field I'm concerning, say 2 text fields, 1 grid window and 2 other buttons. At grid window I want to use to control the grid window and other 2 text fields in form1 to make it as enabled=.f., and 2 buttons as enabled=.f..

    Can I write as follows:

         do form form2 with thisform.text1.value, thisform.text2.value, thisform.grid1.enabled, thisform.addbtn.enabled, thisform.editbtn.enabled

    lparameter m.form1_value,m.grid1_enabled,m.addbtn_enabled,editbtn_enabled

    LVL 3

    Accepted Solution

    Dear Sam

    I think I didnt follow ...
    You are passing 2 text values
    and 3 logical values ....

    you can accept them in the second form
    What you want to do with the other values ?

    If you want those to be used across the form, you can create form level properties and set it in that.

    do form form2 with thisform.text1.value, thisform.text2.value, thisform.grid1.enabled, thisform.addbtn.enabled, thisform.editbtn.enabled

    The Other form
    Init method
    lparameter m.form1_value,m.form2_value,m.grid1_enabled,m.addbtn_enabled,editbtn_enabled

    thisform.text2.value = m.form1_value
    thisform.Searchval = m.form2value && this search value can be used in some other method too in this form.

    thisform.grid1.enabled = m.grid1_enabled && or whatever you want.

    I think 18 parmaters can be sent ... I am not sure.... It depends on what is the requirement ...


    LVL 2

    Expert Comment

    I will put them in session variable


    on code behind of form 2:

    on code behind of form 1:

    Author Comment

    Hi All,

    This question seemed open for long, and I had found another way out to solve it. Thanks for all of you sharing your time with your precious solutions.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now