Jump to content

Need help resetting serial number after import


This topic is 6098 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Here's what I'm attempting: In an upgrade script that imports the user's data from a previous version, I can't figure out how to change the next serial number in the Define menu to the serial number of the last record imported plus 1, so that the next new record the user makes has the right number. Can anyone give me some ideas? Thanks a million.

Link to comment
Share on other sites

I don't think so. I don't see why "123" should become "25", and you can certainly set next serial value to "ABC123" and have the subsequent new records receive the values of ""ABC123", "ABC124" etc. (though it's best for the serial field to be Text in such case).

Link to comment
Share on other sites

Sorry, the "might" become 25 was purely a (bad) example, however I am correct about the non-numeric part of a serial number, see this extract from the on-line help. I also have experienced this too.

The following example calculates the number of the next available invoice ID. If the invoice ID contains non-numeric data, then the calculation would need to be more sophisticated to maintain the numeric and non-numeric data.

Go to Record/Request/Page [Last]

Set Next Serial Value [Table1::Invoice ID; Table1::InvoiceID + 1]

Link to comment
Share on other sites

I am afraid you are confusing two separate issues:

Set Next Serial Value [ Table::SerialID ; "ABC123" ]

will work perfectly, and the next two records will be issued SerialIDs "ABC123" and "ABC124", respectively. However, the following will not work very well:

Set Next Serial Value [ Table::SerialID ; "ABC122" + 1 ]

Here the next two records will receive values of "123" and "124". But the reason for this has nothing to do with the Set Next Serial Value[] script step. It fails because the calculation is required to perform a numeric operation on a text value, therefore it needs to convert it to a number first. The correct way to do this is:

Set Next Serial Value [ Table::SerialID ; SerialIncrement ( "ABC122" ; 1 ) ]

Link to comment
Share on other sites

Thanks everyone for replies to my question. As it happened, I was creating the correct script step, but because I'd tried so many wrong things first, I didn't see that it worked right because of performing an inadequate test. Just knowing that the steps were right led me to see my problem.

Now, my next question: How do I make this function discretionary, so that if there are no imported records the serial number is not reset? Thanks again.

Link to comment
Share on other sites

Well, who cares? If there were no imported records, the next value in the table is set to 1. That's acceptable.

But you could add:

If get (foundcount)>0

setnextserial

endif

That'll skip the setnextserial on a table with no records.

Link to comment
Share on other sites

Is your Skill Level Correct?

The Get (FoundCount), [color:gray]which was Status (FoundCount) in earlier versions, and can be located in the List of Function.

Click on the "All Functions by name" [color:blue]tab, and you see the Get Functions listed about 3/4 of the way down. [color:blue]Highlight Get Functions, and a whole bunch of Get functions will appear, including the Found Count.

HTH

Lee

Link to comment
Share on other sites

This topic is 6098 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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