bind combo box value to textbox - InfoPath Dev
in

InfoPath Dev

bind combo box value to textbox

Last post 10-12-2007 04:06 AM by adamrharding. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 10-08-2007 04:31 AM

    • zolfj
    • Not Ranked
    • Joined on 10-08-2007
    • Posts 5

    bind combo box value to textbox

     

    hello there,

    i have a repeating table with a combo box which gets its values from the db.now i want to populate other table column based on the value selected from the combo box.please guide me to do this.

     thanks in advance

     cheers

    zolf

  • 10-08-2007 05:43 AM In reply to

    Re: bind combo box value to textbox

    Hello
     
    Select the Second Repeating Table and Right click on it and select Change Binding
    Select the First Repeating table in the window that Pops up and click Next
    Select the field that you want to Populate and add
    click OK to Save changes
     
    I hope this will help you
    Kalyan G Reddy
    Infopath MVP 2007 and 2008
  • 10-08-2007 08:57 PM In reply to

    • zolfj
    • Not Ranked
    • Joined on 10-08-2007
    • Posts 5

    Re: bind combo box value to textbox

     

    thanks for your comment,Kalyan 

    let me expalin again.

    i first inserted a repeating table with 5 columns.the first column i changed it to combo box and fill it with data from the db.this first column gets the product name.which works good.now i want to be able to fill the second column with the unit price of the product selected in the combo box.but i just cant fill that column.please bear with me and help me i need that very badly.appreciate your help.

     

    cheers

    zolf

  • 10-08-2007 10:39 PM In reply to

    • zolfj
    • Not Ranked
    • Joined on 10-08-2007
    • Posts 5

    Re: bind combo box value to textbox

     

    I tried to follow this tutorial.but the only difference is that i am using database whereas the tutorial uses XXML.but that should not make a big difference.when i preview and select a value from the combo box i get the value of the first product name in the db.then when i select any other product nothing happens.in that tutorial it had mentioned  this

    xdXDocument:GetDOM("Clients")/ClientInfo/Clients/Client/Name[../ID = current()]

     

    but in my case i mean db i have this

    xdXDocument:GetDOM("Product")/dfs:myFields/dfs:dataFields/d:Product/@PName

     

    please help me.the tutorial i was following is

     http://www.infopathdev.com/blogs/matt/archive/2006/04/18/Automatically-Populate-Fields-from-a-Drop_2D00_Down-Selection.aspx

  • 10-09-2007 01:33 AM In reply to

    Re: bind combo box value to textbox

    Hi

    Looking at the tutorial I happened to notice that instead of a combo box the tutorial uses the drop-down list box but having tested them both it makes no difference.

    If we were following the example the specific piece of work that is causing your issue is the Rule mentioned from step 6 on. 

    I would perform the tasks in this order to create the effect you desire:

    1. Select your @PName field
    2. Click 'Rules'
    3. Click 'Add'
    4. Set condition to say where @PName is not blank. (later we will zero out the @UnitPrice field where @PName is blank)
    5. Click 'Add Action'
    6. Select 'Set a field's value'
    7. Select the @UnitPrice field as the 'Field'
    8. Click fx in the 'Value' box
    9. Select 'Insert Field or Group'
    10. Change the 'Data source' to your secondary data source
    11. Select the field in your secondary data source that represents the unit price, maybe @Price
    12. Now click 'Filter Data'
    13. Then 'Add'
    14. On the left-hand-side you want to select the field in your secondary data source that represents the @PName, maybe @Product
    15. On the right-hand-side change the datasource back to 'Main Connection' and choose @Pname
    16. The end result is that you have told the rule to set @UnitPrice to @Price where @Product is equal to the @Pname you have selected.
    17. Now, for completeness add another rule on @PName where @PName is blank set @UnitPrice to 0

    OK sorry that took so long but i think it should help, my statement with the above says @Price[@Product = current()] which is a shortened form of

    @Price where /../@Product = current()/../@Pname

    I think this is pretty exhaustive but any problems I am happy to help

    Adam

    Adam Harding
    Wales
    UK
  • 10-09-2007 09:03 PM In reply to

    • zolfj
    • Not Ranked
    • Joined on 10-08-2007
    • Posts 5

    Re: bind combo box value to textbox

     

    Thanks mate,for your help.that comment of yours was to the point.i managed to get that to work.

    One another question I have is now that i have this working.can i save these data in a db.i mean suppose i added three product and it also gave me the grand total.now i want to save these data in the db for a particular customer.is it possible.if yes please guide me.

    appreciate your time and help.

    cheers

    zolf

  • 10-10-2007 04:24 AM In reply to

    Re: bind combo box value to textbox

    zolfj

    Glad to be of help.

    To get this to work in a database you would have to have two tables in a one-to-many relationship with the grand total on the one side of the relationship and the values on the many side of the realtionship

    For example

    Master Table                                                                               Daughter Table

    Total Cost                                                                                     Cost

    Name                                                                                            Description

    Primary Key                                                                                  Daughter Key

    etc

     

    Then set the default value of @Total_Cost to sum(@Cost) and it will work fine.

    Cheers

     

    Adam Harding
    Wales
    UK
  • 10-10-2007 09:27 PM In reply to

    • zolfj
    • Not Ranked
    • Joined on 10-08-2007
    • Posts 5

    Re: bind combo box value to textbox

     

    Hello Adam,

     I have these three tables Products(ProductID,PName,PCost),Customer(CustomerID,CFName,CLName),CustProduct(CPID,ProductID,CustomerID).

    I have created a form which displays

    Product Name | UnitPrice | Quantity | Total

    1. abc                12             1             12

    2. xyz                5               2             10

    3.pqr                  4              1               4

                                    Grand Total    26

     

    now the product name and unit price i get from the db which you told me how.now when i finish as shown above.i want to submit the form to save it in a db for a particular user.for example customer Tom

    will have those product table displayed when i select tom from another form.please tell me how can i save these 3 products together when i clcik on a submit button.

    cheers

    zolf

  • 10-12-2007 04:06 AM In reply to

    Re: bind combo box value to textbox

    Hello again

    First point to note, you will have to recreate your form from scratch if you now need to link it to a database, unless you are using something like QDabra Database Accelerator that allows this functionality.  Make sure your tables are set out as below before starting the redesign.

    You need to add a couple of fields to your CustProduct table like @PName, @UnitPrice, @Quantity and @Total, that way all the fields displayed on the form are recorded in the database.  Oh, and you will need to add @GrandTotal to the Customer table.

    To get this set up on the form you add the Customer table as the main table in the main data connection then add the CustProduct table linking the field CustomerID on the Customer table to CustomerID on the Cust Product table, this way, for each 1 line in Customer the form can have many lines in Cust Product.

    Now you have linked in your database tables, you can redesign the form and link your repeating table to CustProduct table and delete out @CPID, @Customer ID and @Product ID from the form as the person filling in the form does not need to see these fields.

    So I fill in the form now by entering my First Name into @CFName text box, my Last Name into @CLName.  I then add my products into the repeating table bound to CustProduct, press submit and the @CFName, @CLName and @Customer ID are submitted to the Customer table and all the other fields are submitted to Cust Product.

    Cheers

    Adam Harding
    Wales
    UK
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.