Cannot add records to table when autonumber is used.

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(?).
 
D

Duane Hookom

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

Sam

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

Duane Hookom

I would test this by hard-coding values in place of your memory variables.
Try different experiments with and without quotes etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top