Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'insert into' correct syntax please

Status
Not open for further replies.

ProgramError

Programmer
Mar 2, 2005
1,027
GB
I created the following code which causes a 'cannot add records to table due to key violations.

strsql = "INSERT INTO oddsnendsdata (oddsnendsqueryinput) values (" & numb & ")"

although when I change the statement to...

strsql = "INSERT INTO oddsnendsdata (oddsnendsqueryinput) values (12345)"

It adds them without a problem

the field in the table is a long integer. The variable numb is a long interger. I've tried it with and without assigning the field as a key, no duplicates and the required property of the field is not set. There is only one field in the table which the information is being appened and there is a relationship of the field to a main table autonumber field.

Hellp....

Ian Mayor (UK)
Program Error
Programming is 1% coding, 50% error checking and 49% sweat as your application bombs out in front of the client.
 
Think I may have worked this one out.

Because the main table and the appending table have a relationship (the main having a key autonumber) I cannot append the new value because it does not exsist in the main table YET. I will try and append to the table after i have added the record to the main table first. Wish me luck


Ian Mayor (UK)
Program Error
Programming is 1% coding, 50% error checking and 49% sweat as your application bombs out in front of the client.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top