Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Losing pointer in parent table

Featured Replies

I have a flat file table and I'm looping thru each record and creating new records in a child table.

As I'm looping thru in order to create the child record I use a New Window command, Goto Layout, Set my fields, Commit record and then close the window.

But what I'm finding is that I'm getting duplicate records in my child table. The looping seems to go thru ok part of the way but then for some reason it will go back some records and start over. I'm not sure why I'm losing the pointer in my parent table. I'm thinking it has something to do with the New Window command.

Any ideas?

Dom

You're capturing the parent ID in a variable, too, correct?

So it's:

Loop

set $parentID to ParentID

New Window

Go to Layout Child

New Record

Set foreign key to $parentID

Close Window

Go to Next Record (exit after last)

End Loop

  • Author

Yes I am - thats exactly how I'm doing it.

Well, I'd say something's different, as you wouldn't end up with duplicate children with this script. Post your script? (You can print to pdf and post that or unload a zip of the file).

My goodness, quite a script.

Without the relationship graph, it is difficult to understand what setting SOP to SOP Form::_SOPID; $ForeignKey does. What is the name of the child table here?

Could this be done via an import?

Edited by Guest

There's something peculiar about the subscript as the second last "End If" is not indented correctly, but that might just be the way it printed - but the script could also be corrupt!

You could simplify the subscript too.

1. The New Window command only needs to appear once, place it immediately after the first IF statement. The window does not need to be named as your script doesn't make a reference by name to the window

2. The show/hide and adjust window commands are not required.

3. The commit records is also not required (although it is good practise) as the following close window will do this any way.

The current script requires that all the parameters are found - if the first block of tests fails then there is no default result and the script will not create a new window nor change layout. It will also execute the close window and close your original window under these conditions.

Do you know how to use the script debugger? You can place stop points in the script to monitor it as it runs and also see the $vars and other field values as they happen.

  • Author

Thank you all for your input. I found out the problem. My script was running correctly - the parent table does not have unique primary keys so it appeared like I was getting duplicate records but that begs a totally different issue altogether - why is the key field not unique.

Thank you all again for your input.

Out of curiosity, what are your table names? I couldn't figure them out from your script.

why is the key field not unique

Use an Auto enter SERIAL for the key field.

Is it possible you have reset the serial value, either manually or scripted?

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.