Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Copy data from duplicated subform table instances using a checkbox

Avatar

Level 1

Hi

I've trawled through every answered page on this forum without finding the answer to this question.  Hopefully someone out there will be able to help.

I have a table in a repeating subform.  The data entered into the inital table may (or may not) need to be replicated in the following instance of the table.

I'd like to be able to place a checkbox above the table that if checked will populate the new instance of the table with the data from the first instance (and so on if multiple instances are required).  I thought about global binding but I really need the option of the checkbox (or radio button if someone feels this would be a better option) as the second (or third) instance of the table may need to contain different data than the first table.

Any suggestions for this would be MUCH appreciated.

Regards

Michael

0 Replies

Avatar

Level 10

Hi Michael,

I have a few examples here of similar functionality.

The first one repeats the data in the table if the field is not null. This is so the table only prints rows that contain data. The blog goes into a bit of detail: http://assure.ly/fpiuQK, but you can download the form here: http://assure.ly/hZFh1S. You should have a look at the second 'print' button.

The second example duplicates the data from one table to another. Because in a dynamic table you cannot use the global binding property, this solution involves some script in the exit event. http://assure.ly/hwIaaw.

Our site seems a little slow this morning, so please be patient. I'll put a bit more coal in the burner.

Hope that helps,

Niall

Assure Dynamics

Avatar

Level 1

Thanks Niall for the prompt response.  I had actually come across both examples in my searching, however my form contains one table on a page.  If the user clicks a button (Add Another Location) the form replicates this page (along with a number of other pages, thus giving me a new blank table).  It is at this point that I would like the option of being able to copy the data from the first table instance into the second and so on but only if needed (hence the idea of using a checkbox to trigger the process).

Hope this sheds a little more light on my problem.

If this is somewhat confusing I'm more than happy to send you a copy of the file so you can have a look.

Regards

Michael

Avatar

Level 10

Hi Michael,

I think the basic approach can be adapted to suit your case. Basically you would need to set up a loop to run through the rows in the previous instance of the table and look at the value in the checkboxes.

A couple of things:

  • Is the table static, or can the user add rows to the table?
  • If there are more than two instances of the tables, does the user want to replicate data from the first instance of the table always? Or do that want to replicate data from the previous instance?
  • Where is the checkbox in the table? Is it in the first row or are there checkboxes in every row?

I think the first example: Assure Dynamics Duplicate table data if not null.pdf is very close to what you want. The only thing left to script is the target instance of the table that you want.

I am in/out of the office at the moment, but if you upload the form to a file sharing site and post the published link here I will try and have a look.

Niall

Avatar

Level 1

Hi Niall

Here's the link

https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0B2EWlBgk_NsHNjBiNGRiMmMtZDZiZC00M...

The table is found on the second last page.

You can add rows to the table.

There could be more than two instances of the table but for my purposes replicating data from the first instance is all that's necessary.

The checkbox in the first instance is hidden until a "New Location" has been added and currently sits outside the table as a question.

Cheers

Michael

Avatar

Level 10

Sorry Michael, I was out today and will be on the missing list tomorrow as well. The earliest I will get to look at this will be Friday.

Having just a quick look though, I think that there may be a few issues. With the checkbox there are two criteria resulting in the data being copied down: (1) if the checkbox is selected when the add instance is clicked, and (2) when the checkbox is ticked and there is more than one instance of the table.

Taking the checkbox approach, I think you would also need to have the script fire when the checkbox is ticked to 1. For example, if the user adds more instances and fills in, say three instances of the table. If they then went back and ticked the checkbox, what action do you want?

I think a more direct route would be a button that appears above the table in the second and subsequent instance. The caption would be "Copy your information from the previous table", or something similar. This is a more positive action that is applied at whatever instance of the table that the user wants. In addition the table, the button and the result when its clicked are all in the same view.

Niall

Avatar

Level 1

Hi Niall

I agree with your suggestion of using a button for this.  What are the chances of being able to send you the .tds file so you can give me some direction regarding the scripting I may need to get it working.

Additionally I would probably like to see the button populate a new instance of the table with the data from the previous instance (as opposed to taking the data from the very first instance each time).

Thanks again for your help, much appreciated.

Michael