MS Office Forum / General MS InfoPath Questions / July 2007
After Change on a Drop Down list box, text box changes
|
|
Thread rating:  |
NikV - 23 Aug 2005 16:17 GMT I have a Non repeating drop down list box and a text box that is using an xml data source. If the user chooses something in the drop down, it should change the text box. For example, if the user chooses ProjectNumber from the dropdown the text box should show the ProjectName. How can I get this done? I am very new at this; please help.
Scott L. Heim [MSFT] - 23 Aug 2005 21:26 GMT Hi,
You can use a "Rule" to accomplish what you need:
- Right-click on your drop-down list box and choose Properties - Click the Rules button - Click Add - Click Add Action - From the Action box select: Set a field's value - Click the button next to the Field box, highlight your text box and click OK - Click the button next to the Value box, click Insert Field or Group, highlight your drop-down list box field and click OK - Click OK 5 times to get back to your form in Design View and test!
** NOTE: Please be sure you have a backup copy of your form and these steps will only work as is if your drop-down list box and text box are *not* in a repeating table or section. If they are, these will need to be modified.
I hope this helps!
Scott L. Heim Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights
r_c_autrey - 23 Aug 2005 23:34 GMT Hi Scott,
Your solution results in the ddl selection being put into the textbox. If I wanted to put information from another data source into the textbox, how would I go about doing so. I want to be able to make a selection from my ddl and have several textboxes auto-populate with different info based on my ddl choice.
An example, I choose a contact from a list of names. Based on the contact's id, the address, phone number, and email address textboxes are populated. FYI, this is not in a repeating section or table. I would also like to know how to do it in a repeating section as well if you could point me in the right direction. Thanks!!
Chris
> Hi, > [quoted text clipped - 21 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights Scott L. Heim [MSFT] - 24 Aug 2005 13:30 GMT Hi Chris,
Let's try these steps and see if they achieve what you desire:
- Create a new, blank InfoPath solution - Add a drop-down list named: ddlOrders - Add a text box named: txtCustomerID - Add a text box named: txtFreight - Add a "Receive" data connection to the Northwind Orders table (you can use either the Access or SQL Server version) - Right-click on ddlOrders and choose Properties - In the List Box Entries section, select the option: "Look up values in a data connection to a database..." - From the Data Connection box select Orders - Click the "Select XPath" button next to Entries, highlight "d:Orders" and click OK - Leave the Value and Display Name fields to the default: @OrderID - Click the Rules button - Click Add - Click Add Action - From the Action box select: "Set a field's value" - Click the button next to Field - From the Data source box select Main, highlight txtCustomerID and click OK - Click the button next to Value - Click Insert Field or Group - From the Data source box select Orders - Expand the fields until you can highlight CustomerID - Click the Filter Data button - Click Add - In the first box select OrderID - In the second box select "is equal to" - In the last box choose "Select a field or group" - From the Data source box select Main, highlight ddlOrders and click OK - Click OK 5 times to get back to the Rule screen - Click Add Action - From the Action box select: "Set a field's value" - Click the button next to Field - From the Data source box select Main, highlight txtFreight and click OK - Click the button next to Value - Click Insert Field or Group - From the Data source box select Orders - Expand the fields until you can highlight Freight - Click the Filter Data button - Click Add - In the first box select OrderID - In the second box select "is equal to" - In the last box choose "Select a field or group" - From the Data source box select Main, highlight ddlOrders and click OK - Click OK 8 times to get back to your form - Preview and select an OrderID - it should set the CustomerID and freight information
Let me know if this is what you need!
Scott L. Heim Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights
NikV - 24 Aug 2005 15:39 GMT Thanks Scott for your response. I've fiddled with your below instructions and it works perfectly with one data source. In my situation I have two XML files that were generated from a database. The two XML file have one common "tag" or "field". This field is named ProjectNumber.
In my InfoPath form I have one drop list and two text boxes. The drop down list will hold the ProjectNumber from the first XML file. One of the text boxes will hold the ProjectName from the first XML file. The other text boxes will hold the PlannedExpense from the second XML file.
Every time a user chooses an item in the drop down list box the other two text boxes will populate information from the XML file(s). Can this be done with InfoPath? Hope this make sense. Please help. Thanks!
***1st XML File***
<?xml version="1.0" ?> - <NIK_TABLE> <NIK_ProjectInfo ProjectName="MTV" ProjectNumber="F1980" ProjectDesc="Music Television" ProjectManager="Doug Westrum" ManagerPhone="452-325-8340" ProjectStartDate="1980-08-05T00:00:00" ProjectEndDate="2006-11-30T00:00:00" SOWComplete="YES" /> <NIK_ProjectInfo ProjectName="Next Generation Toddler" ProjectNumber="F8642" ProjectDesc="Toys for Kids" ProjectManager="Jack Dobrushin" ManagerPhone="641-689-4230" ProjectStartDate="1813-02-01T00:00:00" ProjectEndDate="2005-09-08T00:00:00" SOWComplete="YES" /> <NIK_ProjectInfo ProjectName="SCI" ProjectNumber="F8661" ProjectDesc="Some Computer Input" ProjectManager="Jack Dobrushin" ManagerPhone="641-689-4230" ProjectStartDate="1910-02-05T00:00:00" ProjectEndDate="2006-10-01T00:00:00" SOWComplete="NO" /> <NIK_ProjectInfo ProjectName="AOW" ProjectNumber="F8821" ProjectDesc="American Open Work" ProjectManager="Lynn Humphrey" ManagerPhone="515-288-8240" ProjectStartDate="1980-02-08T00:00:00" ProjectEndDate="2005-10-30T00:00:00" SOWComplete="YES" /> </NIK_TABLE>
***2nd XML File***
<?xml version="1.0" ?> - <NIK_TABLE> <NIK_FTS ProjectNumber="F8221" PlannedExpense="1000" Depreciation="1002" LaborCosts="6530" OtherExpense="6500" EstimatetoComplete="5500" /> <NIK_FTS ProjectNumber="F8642" PlannedExpense="10000" Depreciation="15000" LaborCosts="2" OtherExpense="3" EstimatetoComplete="1500000" /> <NIK_FTS ProjectNumber="F8661" PlannedExpense="25001" Depreciation="153200" LaborCosts="152000" OtherExpense="15000" EstimatetoComplete="2000000" /> <NIK_FTS ProjectNumber="F8821" PlannedExpense="12500" Depreciation="123222" LaborCosts="120000" OtherExpense="15000" EstimatetoComplete="200000" /> </NIK_TABLE>
> Hi Chris, > [quoted text clipped - 54 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights Scott L. Heim [MSFT] - 24 Aug 2005 17:07 GMT Hi,
Yes - this will work. You will need to add both XML files as "data connections" but the basic steps I provided will still work for you. In your case when you start the "filtering" process you will simply need to reference the appropriate XML file (data connection.)
Let me know if you need more direction on this...
Scott L. Heim Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights
NikV - 24 Aug 2005 17:29 GMT Scott; I've added both data connections and did the filter as you indicated in your first directions. When I preview the form nothing in the PlannedExpenses text box appears. More direction will be great. Below is my filter:
@PlannedExpense[txt_ProjectNum = @ProjectNumber]
I am referencing whatever is in the Project Number text box to the Project Number in my second XML form. Please help. Thanks!
> Hi, > [quoted text clipped - 9 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights Scott L. Heim [MSFT] - 24 Aug 2005 18:15 GMT Hi,
Here are the exact steps I just completed that appear to work as you need:
- Create a new, blank InfoPath form - Add a drop-down list box - Add a text box named: txtProjectName - Add a text box named: txtPlannedExpense - Add a data connection to the first XML file named: XMLFile1 - Add a data connection to the second XML file named: XMLFile2 - Set the data source of the drop-down list to XMLFile1 and set the Value and Display Name to: @ProjectNumber - With the Properties window still open for the drop-down list box, click the Rules button - Click Add - Click Add Action - From the Action box choose: Set a field's value - Click the button next to the Field box, select txtProjectName and click OK - Click the button next to the Value field - Click Insert Field or Group - From the Data Source box select: XMLFile1 - Highlight ProjectName and then click the Filter Data button - Click Add - In the first box, choose: ProjectNumber - In the second box, choose: is equal to - In the third box, choose: Select a field or group - From the Data Source box choose Main, highlight field1 (the drop-down list) and click OK - Click OK 5 times to get back to the Rule window - Click Add Action - From the Action box choose: Set a field's value - Click the button next to the Field box, select txtPlannedExpense and click OK - Click the button next to the Value field - Click Insert Field or Group - From the Data Source box select: XMLFile2 - Highlight PlannedExpense and then click the Filter Data button - Click Add - In the first box, choose: ProjectNumber - In the second box, choose: is equal to - In the third box, choose: Select a field or group - From the Data Source box choose Main, highlight field1 (the drop-down list) and click OK - Click OK 8 times to get back to your form - Preview and test!
Let me know if these work for you!
Scott L. Heim Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights
NikV - 24 Aug 2005 20:41 GMT You are awesome Scott! Thanks for everything!
> Hi, > [quoted text clipped - 48 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights Scott L. Heim [MSFT] - 24 Aug 2005 21:02 GMT Hi,
Glad I could help!
Take care,
Scott L. Heim Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights
NikV - 08 Sep 2005 15:29 GMT Hi Scott; I have a question. I have a text box in my InfoPath template. The text box will store Milestone dates. For example the data will look like the below when the user enters it in:
9/10/05 Project Kickoff Day 9/15/05 Project Funding Finalized 10/12/05 Ran into some Data problems
After hitting submit in the template, the data will be stored in a database. The database has a trigger which will write an XML file. The XML file is used to populate the text boxes for additional edits in the future. My question is how do I keep the data looking like the above when it's reading from the XML file. The data gets "pushed" and "word wrap" all together. Hope this makes sense. Thanks in advance Scott.
> Hi, > [quoted text clipped - 6 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights Denniso6 - 30 Jul 2007 21:26 GMT Hi Scott...,
What steps might I take if the second control were a drop-down box as well ?
thanks in advance for your assistance.
DennisO -------------------------
> Hi Chris, > [quoted text clipped - 54 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights
|
|
|