In Access have a simple table layout:
And I want to add data to t_Bild. So I have created the query:
INSERT INTO t_Bild ( B_ID, M_ID, Dateiname, Datum )
VALUES (11, 8, "someName.png", DATE());
It works. But I need to get the max value for B_ID dynamically so the query inserts a new private key automatically. So I have modified the query:
INSERT INTO t_Bild ( B_ID, M_ID, Dateiname, Datum )
VALUES ((SELECT 1+ MAX(B_ID) FROM t_Bild), 8, "someName.png", DATE());
But the problem is that each time I run the query no data is inserted. I also do not get any error message back. I have checkt the query:
SELECT 1+ MAX(B_ID) FROM t_Bild;
And it works fine.
How can I achieve to add data to t_Bild with a valid private key?
Note: I am not able to set the private key to autonumber because I forgot to set it while modelling the database. Now Access does not allow me to set the private keys to autonumber anymore.