How to use the value of one field in mutiple record when updating database - InfoPath Dev
in

InfoPath Dev

How to use the value of one field in mutiple record when updating database

Last post 01-14-2009 04:44 PM by Hilary Stoupa. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 01-13-2009 01:41 PM

    How to use the value of one field in mutiple record when updating database

    Hi,

    I am using Infopath2003 still taking baby steps to get familiar with Infopath and i have mixed success. 

     

    DataSource Details: SQL Server

    Table1 have empid and empname 

    Table2 have empname, task, hours. These two tables have relationshiop on empname column.

    The issue that i am facing is that i want to create a time card form which look like this.

    Employee name as drop down list. This field is populated from SQL Server database.  

    A repeating table having "task" and "hours" column.

    So whenever a user open this form, he/she can select his/her name and then add rows to repeating table. And then click on submit button.

    Now when user hit submit button what i want is that Table2 should get populated with "empname, task, hours" for each record. But this is not happening.

    empname is getting inserted for first record only. Other records have empname as blank. How can i make infopath to insert records with empname for every row in this form.

     

    Thanks a lot in advance :)

     

     

  • 01-14-2009 02:45 AM In reply to

    Re: How to use the value of one field in mutiple record when updating database

    First Submit Button is not the way to go, as Submit is used to submit the data to a dataconnection, like webservice, sharepoint, xml file

    When exactly do you want to reach, when the user selects an item from the dropdown, it shows the information, do you want the user to update/change the information,  or is it just for showing ?

    If you give me more info I can bring you into the right direction.

    One hint already is to use filters when the value of the dropdown is changed.

     

     

    Frederik Van Lierde
    Blue InfoPath Blog  ¦  SilverSands Associate  ¦  Do you follow me already?  ¦  We work smart, not hard


    If this article was helpfull, don't forget to rate it, tnx!
  • 01-14-2009 01:18 PM In reply to

    Re: How to use the value of one field in mutiple record when updating database

    Hi Frederik,

    Thanks a lot for replying. But i want to save this data into database. What i want is user opens this form. Select his/her name from EmpName drop down list.

    And in the repeating table add a row, fill Task and Hours. Insert one more row and fill Task and Hours and then hit submit button.

    EmpName John
       
    Task Hours
    Team Meeting 2
    Bug Fixing 6

    Now when submit button is hit, the data that goes to database is

    Empname       Task              Hrs

    John            TeamMeeting       2

                       Bug Fixing           6

     -----------------------------------------------------------------

    But what i want is

    Empname       Task              Hrs

    John            TeamMeeting       2

    John             Bug Fixing           6

     

    I hope you can understand my problem.

     

     

  • 01-14-2009 01:28 PM In reply to

    Re: How to use the value of one field in mutiple record when updating database

    In your data source task pane for the form, I'd guess that the employee name field is in the top group and also repeated in the group which your repeating table is based off of -- is that correct? If so, you could set the default value for that 'child' EmpName field to be the same as the higher level field that your EmpName drop down is bound to.... does that make sense?

    Hilary Stoupa

  • 01-14-2009 04:26 PM In reply to

    Re: How to use the value of one field in mutiple record when updating database

    Hi Hilary,

    Thanks a lot for the reply. Assume i have a simle Table in database emptable with "EmpName", "TaskName" and "Hours" Column. When i design a form i add a drop down list and enter values manually into this drop down list ( e.g. "John", "Mark" etc). Then i select datasource, right click and select repeating table. This repeating table have all the three columns, "EmpName", "TaskName", "Hours". Now i delete EmpName column from the repeating table to avoid duplication of information.

    So when user opens this form, he/she can select his/her name from the drop downlist and then enter values in TaskName and Hours. Then click on Insert item and add one more row to repeating table. Again enter value for TaskName and Hours. Now there are two rows in repeating table. If user hit submit button the values that goes to table is

    EmpName, TaskName, Hours for the first row but for second row only TaskName and Hours. So what i want to achieve is that whatever value is selected in EmpName dropdown list that value should get inserted to database for each row on submit.

     

    Thanks a lot for for your patience to read it all through :)

     

     

     

     

  • 01-14-2009 04:44 PM In reply to

    Re: How to use the value of one field in mutiple record when updating database

    And what I am suggesting is that you click on the EmpName field in your data source task pane (where you clicked on the group for the repeating table) and set the default value to equal the data node that the drop down you created is bound to. That way, when they select the value from the drop down, all the rows in the repeating table get set to that. I'm including a simple sample form with this post -- just right click the link in the header to the post, select 'Save Target As' and save the file locally. Open in design mode and preview the form to see how it works....

    Hilary Stoupa

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