Reputation: 5961
AM querying an access database from vb6 using the following query
INSERT INTO stock([i_name],[ref],[qty],[supplier_id])
VALUES('dd','dddd','11',(SELECT id FROM suppliers WHERE s_name ='dangote'))
but i get the following error when i run the query
-2147467259 Unspecified error Microsoft JET Database Engine
can anyone tell me what is wrong
thanks
Upvotes: 1
Views: 400
Reputation: 97101
INSERT INTO stock([i_name],[ref],[qty],[supplier_id])
SELECT 'dd','dddd','11',id FROM suppliers WHERE s_name ='dangote';
That looks to me like it should work. If you get an error, try pasting it into SQL View of a new query in Access.
If the field type of qty is numeric rather than text, discard the quotes around the value 11.
INSERT INTO stock([i_name],[ref],[qty],[supplier_id])
SELECT 'dd','dddd',11,id FROM suppliers WHERE s_name ='dangote';
Upvotes: 2