Subject Re: autoincrement problem
From Charlie <tm@tc.com>
Date Tue, 17 Oct 2023 02:35:15 -0400
Newsgroups dbase.getting-started

Hi Ken...  Thanks..  I tried that as an xdml function with a variable and then a hard number as below..  Doesn't seem to work for me.  Does the same thing.  New number is starting over.  Any suggestions?

I did have success in dropping the field and then creating it again but that doesn't seem to be very code friendly.

function alttab()
private x
x = 0
use floss.dbf
go bottom
x = lr +1
close tables
set procedure to :dUFLP:DBF7File.CC
oDBF7File = new DBF7File( "floss.dbf" )
oDBF7File.SetNextAutoIncValue( 293 )
oDBF7File = null
close procedure :dUFLP:DBF7File.cc
return


Ken Mayer Wrote:

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