Cannot add records to table when autonumber is used.

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

When trying to add records to an MS access 97 table which
uses "autonumber" field as a primary key, the record(s)
never get added. Example of sq1 script:
$db->Sql( "INSERT INTO Autolog (Date, Vehicle_Type,
Mileage, Service_Type, Cost, Remarks) VALUES
('$Date', '$Vehicle_Type', '$Mileage','$Service_Type
', '$Cost', '$Remarks' )"). The "autonumber" field,
named, "RecNum," is not referenced because the next
sequential number is not known. Can someone perhaps tell
me why the table does not get updated(?).
 
I doubt your issue is with the RecNum field. I expect it has to do with
other field values or data type mismatches. I am not sure but possibly
Mileage is a numeric field so you don't enclose it in ''s.
 
Insert works fine except in the case of trying to insert
records into a table with "autonumber" turned on. If I
assign a record number to the "autonumber field during
an "insert" that, too, works (?). Keep in mind, I
want "autonumber" to select the next sequential number
for the new record since I'm not always sure what
the "next" number will be.
 
I would test this by hard-coding values in place of your memory variables.
Try different experiments with and without quotes etc.
 
Back
Top