I have been running this query for a about 3 weeks now and all of a sudden it stopped working. This is the error I get:
My table is completely empty. Here is the code for the INSERT INTO statement:
SQL$ = ""
SQL$ = SQL$ & " INSERT INTO table1"
SQL$ = SQL$ & " VALUES ('test', 1, '1-1', #01/01/2001#, 1000, 'testing', 'example', 1, 2, 30);
DoCmd.RunSQL SQL$
There is nothing that should be violating the primary key value since there are no records existing. Is there another way to violate the primary key or is this an access issue?
This is the table design:
Ignore the bad field names, I had to change them temporarily so I could post here.
I even tried to run this as an Access query outside of VBA:
SELECT * FROM table1
and it returned nothing.
UPDATE:
This is interesting. So table1 is in a 1 to many relationship, the vNum being the many in table1 as stated earlier. On the 1 side, call the table "oTable", it already had a list of vNum's that I imported from a different database. I recently created a new record in oTable with the vNum called "vTester". In my form for table1 that is generating the above SQL insert statement, I can choose whichever vNum I want from a combobox. The user CANNOT choose one that doesn't exist. In my form I picked "vTester" and got the above errors. When I chose one of the imported vNum's however, the SQL command worked. Any ideas?
col1
string into it. To avoid that, specify column names in your SQL:INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...);
- Stack