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.
Juggernaut

Featured Replies

Okay - Loops should be simple - why do they get the best of me.

Go to Layout (invoice entry)

Go to Record (first)

Loop

Duplicate Record

Go to Record (next, exit after last)

End Loop

I will add the other stuff later - I am just trying to get my base loop to work first. It pulls the first record and then is done - what am I missing.

Thanks for your help

Probably because after the duplicate, you are on the "new" and now "last" record. If your list is unsorted, the new (duplicate) record appears at the end. If it is sorted, it appears after the record you just duplicated. I would try:

Go to Layout (invoice entry)

Sort(restore)

Go to Record (first)

Loop

Duplicate Record

Omit Record

If (Status(CurrentRecordNumber) = Status(CurrentFoundCount)

Duplicate Record

Exit Loop If (1)

End If

End Loop

The extra duplicate is needed to make sure the last records is duplicated. The omit operation automatically moves you to the next record to be duplicated. You can try all the operations manually to verify what is happening.

-bd

  • Author

This scenario that you offered - seems to duplicate twice. Once at the beginning of the loop and then once in the If statement.

That won't work. Other ideas?

Thanks.

This is not too clean but works.

Go to Layout [ Your layout ]

Sort [ Sort Order: Your Sort (Ascending) ]

[ Restore sort order, No dialog ]

Go to Record/Request/Page

[ First ]

Loop

Duplicate Record/Request

Omit Record

Go to Record/Request/Page

[ First ]

Omit Record

Exit Loop If [ Status( CurrentFoundCount) = 0 ]

End Loop

  • Author

Thanks -

That seemed to work.

Sure I will have other questions coming up.

Tweety

Well, if you want to duplicate all records of a found set, here's a simpler solution - why not just export them to a file, import the file with new primary keys, and dump teh exported file?

  • Newbies

Just a thought, if you want to keep all of the records visible using the omit procedure will obviously not work. In all of my tables (files) I create two global fields one named counter (numeric) the other named number, my loop would go like this...

set field["counter", "1"]

set field["number", "Status(CurrentRecordCount)"]

Show all records

Loop

Exit Loop if ["counter=number + 1"]

Go to record ["counter"]

Duplicate Record

set field["counter", "counter+1"]

End Loop

set field["counter",""""]

set field["number_of_records",""""]

It might seem clumsy but it works

Not so (I can tell you didn't try it!). The last duplicate in the "If" is needed to make sure the last record is duplicated. If you leave it out, you will only duplicate n-1 records.

-bd

Create an account or sign in to comment

Important Information

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

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.