Subject Re: autoincrement problem
From Ken Mayer <dbase@nospam.goldenstag.net>
Date Mon, 16 Oct 2023 20:09:35 -0700
Newsgroups dbase.getting-started

On 10/16/2023 4:10 PM, Charlie wrote:
> Hi..  I am using autoincrement field type.  Seems to work ok if I append from a table.  But when I try to add using beginappend() instead of increasing the number in the field it goes back to 1.  I tried alter table but couldn't get that to work either.  I have the field indexed.  Not sure if that could be causing the problem.

The problem is that the append command does not appear to be updating
the internal mechanic in the table that tracks the autoincrement number.
I think this is a known issue, but it's been a long time.

Simple solution (assumes you have the dUFLP set up): Determine what you
want the *next* entry to be (look at the last record, add 1). Write it
down.

In the Command Window, make sure all tables are closed:

close tables

set procedure to :dUFLP:DBF7File.CC
oDBF7File = new DBF7File( "your_table_name.dbf" ) // be sure to include
the extension
oDBF7File.SetNextAutoIncValue( new_value )  // this is the number I told
you to write down
oDBF7File = null
close procedure :dUFLP:DBF7File.cc

That should take care of it.

Ken

--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
dBASE Web Tutorial: http://www.goldenstag.net/dbase/WebTutorial/00_Menu.htm
dBASE DOS to Windows Tutorial:
http://www.goldenstag.net/dbase/DtoWTutorial/00_Menu.htm