append a record to a table using vba where the table contains an autonumber

marky_dp

Registered User.
Local time
Today, 20:29
Joined
Jan 5, 2006
Messages
24
Hi, basically what i want to do is append a record to a table using vba. I would like to take two values from my form (productID, supplierID) and insert them into a table (supplierProductsTBL) under the same headings. I've constructed an sql statement but am getting the following error:

runtime error '3346'

number of query values and destination fields are not the same'

I think this happens because the table also contains an autonumber field (supplierProductID) and i'm not referencing this in my sql statement (below):

mySQL = "INSERT INTO SupplierProductsTBL ( SupplierID, ProductID ) VALUES ('" & SupplierID & "'), ('" & ProductID & "')"

i wuld just get rid of the autonumber field but i need this.

Any help on this would be appreciated, cheers mark
 
Mark,

Its not good form to make duplicate posts. I have already replied to your post in another forum. If you decide you have posted in the wrong place, delete your previous post. Thanks.
 
Not sure if ReclusiveMonkey had the same response but...

1. Don't populate AutoNumber fields.
2. Assuming gthe 2 fields mentioned are not autonumber fields...too many brackets
3. are the ID fields strings? If not, remove single quotes.

mySQL = "INSERT INTO SupplierProductsTBL ( SupplierID, ProductID ) VALUES ('" & SupplierID & "', '" & ProductID & "')"
 

Users who are viewing this thread

Back
Top Bottom