PDA

View Full Version : [SOLVED:] Ghost parameter in Update Query



Bob Phillips
03-05-2022, 10:04 AM
I am sure I am missing the obvious, but here goes anyway.

I have written hundreds of parameterised queries in Access, but I don't recall having this problem before. The following update that should prompt for 3 values prompts for4, an extra value.


UPDATE Product
SET ProductName = param.product, ProductType = param.product.type
WHERE Id = param.id;

As well as the 3 parameters that I have setup, it also prompts for ProductType. What am I missing here?

arnelgp
03-05-2022, 10:05 PM
do you have ProductType fieldname.
make sure your Spelling is correct against the actual fieldname.

arnelgp
03-05-2022, 10:06 PM
do you have ProductType fieldname.
make sure your Spelling is correct against the actual fieldname.
even if you supply the parameter ProductType with any value, the query will fail because
it will not find the field.

Bob Phillips
03-06-2022, 05:32 AM
My first thought when I saw your response was that I have been doing this for decades, do you think I am an idiot. But it turns out I am an idiot. That was exactly the problem, I had renamed ProductType to ProductTypeId (it is a foreign key). My only defence mitigation is that, when looking at the table in Datasheet view, it doesn't show the Id part in the header name, but then, I should have been looking in design view.

Thanks for spurring me to take off the blinkers.

Aussiebear
03-06-2022, 06:56 AM
Off with his head...:jail: