Add repeating section via vb script - InfoPath Dev
in

InfoPath Dev

Add repeating section via vb script

Last post 04-20-2010 03:44 PM by Hilary Stoupa. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 04-01-2010 09:54 AM

    Add repeating section via vb script

     Hello! I'm looking to add a button to my form with code behind the button that will add a repeating section. Basically, vb script that is equivalent to "Insert myrepeating section above".

     Thanks in advance.

  • 04-07-2010 03:17 PM In reply to

    Re: Add repeating section via vb script

    Hi:

    Check out this blog post by Jimmy, or qRules can make this easy for you to do without code!

    Hilary Stoupa

  • 04-08-2010 07:14 AM In reply to

    Re: Add repeating section via vb script

     Thank you. That's what I was looking for. Now I just need to figure our how to make the repeating section appear at the top of the form instead of the bottom...

  • 04-08-2010 07:47 AM In reply to

    Re: Add repeating section via vb script

    In theory, found what I was looking for with "xCollection::insertBefore", but of course that was too easy, so I receive an error message when using that.

  • 04-08-2010 05:36 PM In reply to

    Re: Add repeating section via vb script

    What is the error?

    Hilary Stoupa

  • 04-09-2010 12:37 PM In reply to

    Re: Add repeating section via vb script

    Hi Hilary. I'm off work today so I don't have access to my form to tell you what the error message is. While I have your ear, let me ask you another question, the answer to which may clear up my problem with the error message. Thanks to "xCollection::insert" I can insert the repeating section like I wanted. Let's say I wanted to insert it immediately after a particular repeating table on my form. Is that possible? If so, what would the vbscript syntax be for that? Basically, I'm looking for the repeating section to be inserted in a particular spot on my form (the user will do this via a button on the form). I've got the button on the form and the insert code behind it (which works), I just don't know  how  to control the placement of the repeating section on the form.

    Thanks for all your help- I appreciate it! 

     

  • 04-09-2010 05:06 PM In reply to

    Re: Add repeating section via vb script

    Hi --

    You can place the control you want on your form in the design view. Then, in Tools / Defaults, you can choose not to have the repeating group bound to that control included when the form is opened. Then your button can use xCollection::insert to insert the repeating section, and the control will show. Is that what you were asking? I may be a little confused. :-)

    Hilary Stoupa

  • 04-12-2010 09:12 AM In reply to

    Re: Add repeating section via vb script

     Hilary, I'm back at work so I can provide more info about my form. As for the error message I spoke of earlier, it was "InfoPath cannot complete this action because of an error in the form's code". If I use xCollection::insert there is no problem. If I use xCollection::insertBefore (or other variations) I receive the error message.

    As for my form, it has two sections- the top section is a repeating table and the second section is a repeating section with a repeating table inside of it. The top section contains employee data- name, unit, supervisor. The 2nd section contains a date field and task/time spent fields. The task field is a drop down box where the employee selects whatever task they worked on. The time spent field is where they record the time spent on any particular task. When the employee opens the form, they put their name in a name query field, then click a query button, which then populates the top section and the 2nd section. So, after running the query, the top section will contain their name, unit and supervisor. The second section shows the dates they worked and the tasks/time spent on each task. The second section is filtered to only show the 6 most recent weeks worked, so the typical user sees about 30 repeating sections worth of dates worked and the tasks/time spent for those days.

     As it stands, when the user clicks the add section button I'm attempting to add to the form, it puts the new section at the bottom of the form (after the last repeating section), which requires the user to scroll all the way to the bottom of the form to fill it out. What I'm trying to accomplish is to have the new section be inserted immediately below the top section and above the most recently dated 2nd section, basically in between the two. Does that make sense? Let me know if you need further info and thanks again for your help!

     

     

  • 04-17-2010 04:54 AM In reply to

    Re: Add repeating section via vb script

    MSDN says:

    Note  In some cases, calling the ExecuteAction method from the OnClick event for a button in a view may cause an error. This is because the selected context changes to the button when the button is clicked. In this case, it is better to use a button (or link) on a custom task pane, toolbar, or menu to call the ExecuteAction method.

    Which may be what you are running into. I found that if I put the button inside the repeating table / section I wanted to use the insert before action on, it worked. You could do that, then use conditional formatting to hide your button unless it was in the first instance of the group.

    Hilary Stoupa

  • 04-19-2010 03:31 AM In reply to

    Re: Add repeating section via vb script

    is there any way to hide menu bar in infopath 2003 form  and restrict user to see only their items using form template.

  • 04-19-2010 08:59 AM In reply to

    Re: Add repeating section via vb script

     Hi again Hilary. I think we're almost there. I understand the conditional formatting concept, but how do I set the "first instance of the group" condition/part?

  • 04-20-2010 03:44 PM In reply to

    Re: Add repeating section via vb script

    In the conditional formatting for your button, set the first dropdown to "The Expression". Type in position() != 1. This will hide your button for all but the first group.

    Hilary Stoupa

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