DLookup/Dmax function error after append query
I have the following problem that emerged in my database.
I have a table with alphanumeric id. I need to know the last one when i enter new data using an entry form. So on the entry form i have an unbound control with Dlookup/Dmax function. The function runs on a query based on the given table. Everything worked fine until i have ran an append query than added records to this table. The combined Dlookup/Dmax function results in an error.
So i copied the table, deleted all records and with copy/paste i entered all data again. Function works now. I suppose something with the primary key happened that has an autonumber field.
The combined Dlookup/Dmax function looks up a value from the query where a serial number has its max:
=DLookUp("[HUN_ID]","qrLastIMfrmCSBJ","Year=2019 And Serial=" & DMax("Serial","qrLastIMfrmCSBJ","Year='2019'"))
So my very question is why this happens? The append query did not have any autonumbered field just data for the first two columns of the table.
If the problem is caused by the autonumber field how can i restore the primary key?