[SOLVED] TDBf Primary Fields lazarus / 16-Databases ---------------------------------------------------------------------- 1HuntnMan · 2024-02-05 20:50 Has anyone questioned why when adding the first record to a Dbf table containing a AutoInc-primary field, that field's value is assigned 0 instead of 1?  This was a question I was asked by one of my users who is testing this new app? I'm relatively new to programming. So, I went into the system and in every table with a primary AutoInc primary field I added a new record first, copied it to a new record and then deleted the 0 record.  Now the 3 people testing this new app are happier because there are no 0 records  ! ---------------------------------------------------------------------- Zvoni · 2024-02-06 07:33 What's wrong with 0 for a (Primary Key?) Auto-Inc-Field? It's a value you (and anyone else) shouldn't be interested in at all ---------------------------------------------------------------------- korba812 · 2024-02-06 11:41 Quote from: Zvoni on February 06, 2024, 08:33:23 amWhat's wrong with 0 for a (Primary Key?) Auto-Inc-Field? It's a value you (and anyone else) shouldn't be interested in at all In the case of DBF, this is important because standard numeric fields do not know NULL value and the zero (0) value is used instead. Most Auto-Inc implementations in DBF number from 1. ---------------------------------------------------------------------- Zvoni · 2024-02-06 14:31 Quote from: korba812 on February 06, 2024, 12:41:26 pmIn the case of DBF, this is important because standard numeric fields do not know NULL value and the zero (0) value is used instead. Most Auto-Inc implementations in DBF number from 1. OK. Accepted. Didn't know that, since the last time i was in "contact" with dBase was 1996 in economic school EDIT: Found something in "...\source\packages\fcl- db\src\dbase\dbf_dbffile.pas" Line 854 (FPC3.2.2 - 32Bit) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  // Update our field list      with FFieldDefs.AddFieldDef do      begin        Assign(lFieldDef);        Offset := lFieldOffset;        AutoInc := 0;      end;There. AutoInc:=0; and looking further through the file, any mention of "AutoInc" that has a direct assignment, assigns "0", even "local" variables containing "AutoInc" in its name https://www.freepascal.org/daily/packages/fcl- db/dbf_fields/tdbffielddef.html As far as i understand it: If you create everything from FPC-Code, you should be able to set AutoInc to whatever Startvalue you want (Don't forget AutoIncStep) when you create the FieldDefs. ---------------------------------------------------------------------- 1HuntnMan · 2024-02-11 21:34 I totally agree and understand that a Primary/AutoInc field starts with 0. But, the users could give a flip. They just don't like a 0 Appointment ID. They want the Appointment No. to be a 1 and increment from there. I guess I should have given them a true Appointment No./ID field instead of using the Primary key. Would be easy to change... Thanks