Copy a fields data to another field - InfoPath Dev
in

InfoPath Dev

Copy a fields data to another field

Last post 02-27-2006 10:42 PM by Patrick Halstead. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-21-2006 08:03 PM

    • Carlos
    • Top 500 Contributor
    • Joined on 01-25-2006
    • Australia
    • Posts 31

    Copy a fields data to another field

    I want to know if its possible to copy the contents of 'Field A' into 'field B' after the submit button (to an SQL DB). So essentially, when the Submit button is pressed, the data that was typed into 'Field A' wiill also copy into 'Field B' ONLY is 'Field B' is NULL. If its not NULL, then it shouldnt copy over the new details.

    Any way of dong this without code, or with code in VBSCRIPT?

    Cheers
  • 02-22-2006 12:27 AM In reply to

    Re: Copy a fields data to another field

    Hi,

    Depend on how you submit to your database if it's with code behind simply add this after your insert! need Help?

    If you do this with a submit button in infopath design mode (connected as a secondary datasource)I think that is impossible to do with the same button.



    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 02-22-2006 02:49 AM In reply to

    Re: Copy a fields data to another field

    Hello
    If i understand you scenario correctly - you want a button that will submit to the database and change the value of Field B. You can do this in Rules if you do not want to use code. Open the submit button properties and change the action to Rules and Custom Code option. Now add two rules on your button, one to submit to the database and the other to copy the data from Field A to Field B. The rules are run in the order they are specified so if you want the data to copied over before you submit to the database then add that rule above the submit rule.

    Shanthi
    InfoPath Dev India
    Shanthi Reddy
  • 02-22-2006 07:09 PM In reply to

    • Carlos
    • Top 500 Contributor
    • Joined on 01-25-2006
    • Australia
    • Posts 31

    Re: Copy a fields data to another field

    The trick here is to copy the contents from one firld to the other only is the field is NULL. Once the field is populated, then it will no longer copy it over. I like to do this in code, but my VBScript isnt very good.

    EG:
    Dim FieldB
    Dim FieldA

    Set FieldB = XDocument.......(form field)
    Set FieldA = XDocument.... (form field)

    If FieldB = ""
    FieldB.text = FieldA.text
    End if

    (yes, its a VERY basic code, but you get the idea)
  • 02-27-2006 09:15 PM In reply to

    • Carlos
    • Top 500 Contributor
    • Joined on 01-25-2006
    • Australia
    • Posts 31

    Re: Copy a fields data to another field

    OK, so I figured it out using no code. What I did was to select FieldA, got to its text properties, Rule and Set Condition "FieldB is blank" with the Action "Set a fields value: @FieldB = @FieldA"

    So it only populates it once to satisfy the FieldB is blank.
  • 02-27-2006 10:42 PM In reply to

    Re: Copy a fields data to another field

    Hey Carlos,
    Great to hear that you got the codeless form working. It's often a hard choice between declarative and programmatic. Declarative is harder to debug, but easier for non-programmers to modify.
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.