Assign textbox value based on dropdown control selection - InfoPath Dev
in

InfoPath Dev

Assign textbox value based on dropdown control selection

Last post 08-04-2014 12:11 AM by Sajan Wadhwa. 19 replies.
Page 1 of 2 (20 items) 1 2 Next >
Sort Posts: Previous Next
  • 03-15-2010 11:19 AM

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Assign textbox value based on dropdown control selection

    I have a dropdown control that lists our customers.  DD value = CCUST Display = CustomerName.  I would like when the user selects a customer name from the dropdown list that the value of their selection gets populated into a textbox. 

    Not sure how to go about doing this.

    Stacie
  • 03-15-2010 11:29 AM In reply to

    Re: Assign textbox value based on dropdown control selection

    Hi Stacie,

    See the sample attached, look at the rule I added to the DD, it has a rule to always set the value of the textbox to the value of the DD.  When you change the DD it changes the text box.

    Is this what you are trying to do?

    Ted

  • 03-15-2010 11:47 AM In reply to

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Re: Assign textbox value based on dropdown control selection

    Yes, thanks Ted!

    Stacie
  • 03-15-2010 12:26 PM In reply to

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Re: Assign textbox value based on dropdown control selection

    I have one additional question.  The solution above works if I want my textbox to equal the value of the dropdown list. What do I need to do if I want the textbox to equal the display of the dropdown list.  I tried to create a rule for this but it doesn't populate the value in the textbox.

    Dropdown list: ddl_jobno: value = job_no, display = job_name 

    Texbox: tbox_jobname

    In my rule I set the value of tbox_jobname = Job_Name[Job_No = ddl_jobno]

    Job_No and Job_Name are fields located in my data source which I also use to populate my dropdown list.

     

     

    Stacie
  • 03-15-2010 01:33 PM In reply to

    Re: Assign textbox value based on dropdown control selection

    Hi Stacie,

    I have modified the dd sample XSN to show you how to filter the data from the secondary data source.  I think this is the result that you want.

    Ted

  • 03-15-2010 01:56 PM In reply to

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Re: Assign textbox value based on dropdown control selection

    Ted,

    I tried to change your code for my fields/data source and it kept giving me an error.

    My data source is named Jobs. Fields are job_no and job_name

    My dropdown list is named ddl_jobno and the value and display is set to job_no.

    My textbox is named tbox_jobname

    Just to clarify...when a user selects the job_no from the dropdown list the job_name value appears in the textbox.

    Your code was: ID[Customers = FilterName]

    I entered this for my code: Job_No[ddl_JobNo = Job_Name]

    Not sure what I'm doing wrong.

    Stacie
  • 03-15-2010 02:50 PM In reply to

    Re: Assign textbox value based on dropdown control selection

    Stacie,

    See attached, basically your scenario using a 2DS of jobs

    The key is that the you need to filter the data this way:

    JobName[ddl_jobno = ID]

    This means that the job name shown in the text box is for the ID selected in the Main data source = the ID in the secondary data source

    Ted

  • 03-16-2010 06:59 AM In reply to

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Re: Assign textbox value based on dropdown control selection

    Awesome! Thanks Ted.

    Stacie
  • 03-16-2010 11:53 AM In reply to

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Re: Assign textbox value based on dropdown control selection

     Ted,

    I had to make a change to my Jobs data source and now I'm getting the following error with my rule:

     "xdXDocument:GetDOM("Jobs")/dfs:myFields/dfs:dataFields/ns1:GetColumnsXMLStrQueryResponse/ns1:GetColumnsXMLStrQueryResult/Rows/row/Job_Name/ddl_jobno" does not point to a valid location path of a field or group.

    My code is:

    Job_Name[ddl_jobno = Job_No]

     

    Stacie
  • 03-16-2010 11:56 AM In reply to

    Re: Assign textbox value based on dropdown control selection

    Hi Stacie,

    I think you need to refresh your data connectin in InfoPath (just go through the modify options for the data connection and refresh it by following all prompts and saving).  I think that should fix it up - you may need to adjust your rules though if fields have changed.

    Ted

  • 03-16-2010 11:58 AM In reply to

    Re: Assign textbox value based on dropdown control selection

    Hi Stacie,

    Did the xpath (/dfs:myFields/dfs:dataFields/ns1:GetColumnsXMLStrQueryResponse/ns1:GetColumnsXMLStrQueryResult/Rows/row/Job_Name/ddl_jobno) on the 2DS change?


    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 03-16-2010 12:44 PM In reply to

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Re: Assign textbox value based on dropdown control selection

    What does '2DS' stand for?

    I refreshed my datasource also that that didn't help.

     

    Stacie
  • 03-16-2010 02:43 PM In reply to

    • imstac
    • Top 200 Contributor
      Female
    • Joined on 01-13-2010
    • Austin, TX
    • Posts 59

    Re: Assign textbox value based on dropdown control selection

    Hey, I got it working.  I was copying and pasting the value formula into the value field and it didn't like it.  I had to go through the steps of clicking on the icon, selecting my job_name field from my secondary data connection, clicking Filter Data and adding Job_no = ddl_jobno.

    Thanks for your help guys!

    Stacie
  • 02-07-2011 10:32 AM In reply to

    Re: Assign textbox value based on dropdown control selection

    Ted, I came accross this in a web search and found exactly what I am looking to do in your example. I am not as advanced in InfoPath and did not know:

     1. how you created the second data source

    2. add the fields without taking up space on the form

     

    Hopefully you can make it a little simple for me to understand, thanks so much for your time!

  • 02-07-2011 10:57 AM In reply to

    Re: Assign textbox value based on dropdown control selection

    Hi CrystalA,

    I created the secondary data source in MS Access and exported it as XML although you can create the XML resource file any number of ways (notepad for example).  You can also use a SharePoint list as a secondary data source too.

    Not sure what you mean by your second question though.

    Ted

Page 1 of 2 (20 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.