Saving a field back to a data asource(Access) - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Saving a field back to a data asource(Access)

Last post 09-27-2007 11:18 AM by m181354. 23 replies.
Page 1 of 2 (24 items) 1 2 Next >
Sort Posts: Previous Next
  • 09-24-2007 10:08 AM

    Saving a field back to a data asource(Access)

    I am submitting a form back to a data source(Access database).  I want to insert into a field a total value from another field.  Whe I do that the one field updates evey record on the database with the total amount.  When I update the field manually with the total amount, it updates correctly(just the one record). 

    Do you know how I can insert the value from amother field and update just the one record that I am currently on?  I am using repeating tables and an autonum for the key on the database.

     

     

     

     

     

  • 09-24-2007 10:22 AM In reply to

    Re: Saving a field back to a data asource(Access)

    You want to look at the current() function, lots of examples on the site here. That will allow you to specify which row to update instead of the default which is all.

    If you are creating enterprise form solutions with a database on the backend, you may want to check out the Database Accelerator if you have not already.  It gives you lots of advantages and features which are not possible in the standard Infopath Database form template. Qdabra Database Accelerator Suite Version 2.1.2815 - Developer

     

    Good Luck

    Filed under:
  • 09-24-2007 11:47 AM In reply to

    Re: Saving a field back to a data a source(Access)

    Do you mean this posting below?  Where do you find the manifest.xsf file?  If I need to code...do you have an example? I need to update the row in the table that matches the autonumber field(key). I can update the same field on the form that is not part of the repeatig table and it works fine.  But I need to take a Total Amount from a repeating table and save that value to one row in the table.

    If you know the row number you can filter out just that row in your XPath using the '[n]' filter:

    /Root/Table/Row[3]/Field = "value"

    Sets "value" to Field on the 3rd row of the table.

    If you know a filter value you can use that:

    /Root/Table/Row[FilterField = 'FilterValue']/Field = "value"

    Sets "value" to Field on the table row where FilterField = "FilterValue"

    If you are using rules, and you don't filter for a particular row, then yes, all rows will be updated.
     
    If you want, you can use code to solve the problem. That's the safest way. Otherwise, you can create a rule (the kind that updates all rows), and then manually edit the manifest.xsf file to update the xpath for that rule action to include the filter.
  • 09-24-2007 12:13 PM In reply to

    Re: Saving a field back to a data asource(Access)

    With the Database Accelerator, I could do more things without code?  Would I need to redo my form?  

    If I need to code, I would like to get one good example of how to do it.  I could do most things myself if I could start with some sample code and some help putting it together.

  • 09-24-2007 12:23 PM In reply to

    Re: Saving a field back to a data asource(Access)

    True, with the Database Acelerator you have many webservices which allow you to query and submit to the database multiple times without code as additional data connections.

    You would not need to redo your form, although you may find some improvements that could be made to better fit with the DBXL features.

    If you would like a demo or to discuss how it could help you with your solution send me an email.

    To get at the Manifest - save your form in Design mode as the source files and you can edit the Manifest directly.

  • 09-24-2007 01:10 PM In reply to

    Re: Saving a field back to a data a source(Access)

    I would like to take to you about the Database Accelerator, but first I want to get my prototype to the users.  All I need to do is update one field on an Access database from a total line on a repeatable table.

    Are you saying that I can do it by updating the manifest.xls file to get it to work?  Should I just create the Rule, find it in the manifest.xls file and update it to save the record that I am currently on by using the Key from the table?

  • 09-24-2007 01:43 PM In reply to

    Re: Saving a field back to a data a source(Access)

    I have been looking all over for the code to update a single entry in a database from a total value in a repeatable table.  I can learn quickly given some good examples.  is there a step by step method I can look at?

  • 09-24-2007 02:39 PM In reply to

    Re: Saving a field back to a data a source(Access)

    If you just need to filter the record to update, you do not need code.

    You would just need to update the underlying structure.  The InfoPath User Interface does not give you the option of filtering the field to set with a value.  However you can edit the manifest directly to attain this.

    So I would keep your rule in the same, which updates all fields.  I would also test a filter on a test field which does the filteration you want and produces the row value you wish to be updated.

    Then save as source files and browse the folder.

    Open the Manifest with Notepad.  And follow Greg's post to find the formula and inject the filter. Then when you have saved the Manifest. Right click and select design on the Manifest and you can then save that form and it will have the filter on the field.

    Hope this helps.

  • 09-24-2007 03:20 PM In reply to

    Re: Saving a field back to a data a source(Access)

    Looks like this is the line I need to change...

    <xsf:calculatedField target="/dfs:myFields/dfs:dataFields/d:LaborSummary/@NOW_ETC_HRS" expression="../../../my:FormData/my:NOW_ETC_HRS_USER_INPUT_TOTAL[../../my:DetailId = ../../dfs:dataFields/d:LaborSummary/@AUTONUMBER and ../../dfs:dataFields/d:LaborSummary/@DIST_NONDIST = &quot;Non-Dist&quot;]" refresh="onChange"></xsf:calculatedField>

     

    My filters are AUTONUMBER...the key on the access database and the DIST_NONDIST field.  I need to filter on the Key field and DIST_NONDIST  = Non_Dist. 

    So I woiuld take the Greg's example code.../Root/Table/Row[FilterField = 'FilterValue']/Field = "value" and update the code above?
     

     

  • 09-25-2007 09:48 AM In reply to

    Re: Saving a field back to a data a source(Access)

    Could someone help with how I would make the code below work with saving a field back to a data source without saving it to all the records?   

    Looks like this is the line I need to change...

    <xsf:calculatedField target="/dfs:myFields/dfs:dataFields/d:LaborSummary/@NOW_ETC_HRS" expression="../../../my:FormData/my:NOW_ETC_HRS_USER_INPUT_TOTAL[../../my:DetailId = ../../dfs:dataFields/d:LaborSummary/@AUTONUMBER and ../../dfs:dataFields/d:LaborSummary/@DIST_NONDIST = &quot;Non-Dist&quot;]" refresh="onChange"></xsf:calculatedField>

     

    My filters are AUTONUMBER...the key on the access database and the DIST_NONDIST field.  I need to filter on the Key field and DIST_NONDIST  = Non_Dist. 

    So I woiuld take the Greg's example code.../Root/Table/Row[FilterField = 'FilterValue']/Field = "value" and update the code above?

  • 09-25-2007 09:54 AM In reply to

    Re: Saving a field back to a data a source(Access)

    Have you tried it yet?

    I would think your filter would go at the /d:LaborSummary[RecordID = Field]/@NOW_ETC_HRS.  I would be calculating the rowID that needs to be updated. Place that in a field or put the calculation in the filter are there.

    Typically you will have to test a bit till you get it the way you need it.

  • 09-26-2007 05:25 AM In reply to

    Re: Saving a field back to a data a source(Access)

    When I supply the row number directly it works great!  But when I pass it a filter value it does not.  I must have the wrong syntax.  I will show you both ways I am trying it.

    This works... 

    <xsf:calculatedField target="/dfs:myFields/dfs:dataFields/d:LaborSummary[2]/@NOW_ETC_HRS" expression="../../../my:FormData/my:NOW_ETC_HRS_USER_INPUT_TOTAL[../../my:DetailId = ../../dfs:dataFields/d:LaborSummary/[2]" refresh="onChange"></xsf:calculatedField> 

    This does not.  @AUTONUMBER is the filtervalue.  It is the key on the Access database.

    <xsf:calculatedField target="/dfs:myFields/dfs:dataFields/d:LaborSummary[2]/@NOW_ETC_HRS" expression="../../../my:FormData/my:NOW_ETC_HRS_USER_INPUT_TOTAL[../../my:DetailId = ../../dfs:dataFields/d:LaborSummary/[@AUTONUMBER]" refresh="onChange"></xsf:calculatedField> 

    DO YOU KNOW THE RIGHT SYNTAX  TO PASS A FILTER VALUE?

     

  • 09-26-2007 06:17 AM In reply to

    Re: Saving a field back to a data a source(Access)

    Ok, well at least you are making progress.

    The key is the filter value for the target (1st occurenc) not what it is set to (2nd).  I am guessing it is not always row 2 that you wish to update.

    The second issue is that you need to use the complete field reference. It cannot interpret @AutoNumber and therefore the filter is unsuccessful. It should at least be my:FormData/@AUTONUMBER or something but you would need to check.

    What I would recommend is to go into designer and set it up there first.  Modify the rule to set @NOW_ETC_HOURS to NOW_ETC_HRS_USER_INPUT_TOTAL and then use the filter button to add the filter RecordID = @AUTONUMBER.  Then you can go in and copy this filter to where your first 2 is. I would think you do not really need a filter on your value that you are setting but you I think had this working before.  This at least will give you the proper syntax for the filter.

    Good Luck

  • 09-26-2007 06:59 AM In reply to

    Re: Saving a field back to a data a source(Access)

    I already added the filter and tried to copy it but I still must be missing something or have the wrong syntax.  The filter value comes from a data source so I used the following as the filters...

    ../../dfs:dataFields/d:LaborSummary/[@AUTONUMBER]

    or

     my:DetailId  - I set this value to @AUONUMBER when I switch views.  When I use this it deletes my reference to the NOW_ETC_HRS_USER_INPUT_TOTAL value and does not update.

    Here is the entire line...

    <xsf:calculatedField target="/dfs:myFields/dfs:dataFields/d:LaborSummary[../../dfs:dataFields/d:LaborSummary/@AUTONUMBER]/@NOW_ETC_HRS" expression="../../../my:FormData/my:NOW_ETC_HRS_USER_INPUT_TOTAL[../../my:DetailId = ../../dfs:dataFields/d:LaborSummary/@AUTONUMBER]" refresh="onChange"></xsf:calculatedField>

    Here is the filter line in the form... 

    my:FormData/my:NOW_ETC_HRS_USER_INPUT_TOTAL[../../my:DetailId = ../../dfs:dataFields/d:LaborSummary/[@AUTONUMBER]"

  • 09-26-2007 07:55 AM In reply to

    Re: Saving a field back to a data a source(Access)

    Can you post the text for the one that worked but set all rows to the same total?

    In the lst filter line it would need the ../../ before my:FormData probably.

    I am still confused on what exactly you are trying to do. Maybe you could give some more high level details.

    The user gives some input, selects a row of information or something, and then you are trying to set a total and update that same record correct?

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