I want to change foreign key IDs in a table using an update query and I have hardcoded the ID value in VBA. This feels like the wrong approach so I searched and found this discussion:
stackoverflow.com/questions/1650309/getting-rid-of-hard-coded-values-when-dealing-with-lookup-tables-and-related-bus
This question was asked 14 years ago and I'm curious what the current consensus is on hardcoding IDs in update queries and if Access offers an alternative method (the question was for sql server).
The only solution I can think of for getting rid of hard coded values in Access is to use Dlookup. For the rental service example (UPDATE Items SET State = 1), replace 1 with DLookup("ID", "State", "State = 'Available'").
But for this rental service scenario I might be inclined to delete the ItemState table and change the ItemState field into a text field. If this is for something like a local tool rental company, the total inventory may only be in the hundreds and having an ItemState table may not be necessary. I often think I have normalized my own database too far, and while I notice no speed difference in having multiple lookup tables it is something that lingers in the back of my mind.
stackoverflow.com/questions/1650309/getting-rid-of-hard-coded-values-when-dealing-with-lookup-tables-and-related-bus
This question was asked 14 years ago and I'm curious what the current consensus is on hardcoding IDs in update queries and if Access offers an alternative method (the question was for sql server).
The only solution I can think of for getting rid of hard coded values in Access is to use Dlookup. For the rental service example (UPDATE Items SET State = 1), replace 1 with DLookup("ID", "State", "State = 'Available'").
But for this rental service scenario I might be inclined to delete the ItemState table and change the ItemState field into a text field. If this is for something like a local tool rental company, the total inventory may only be in the hundreds and having an ItemState table may not be necessary. I often think I have normalized my own database too far, and while I notice no speed difference in having multiple lookup tables it is something that lingers in the back of my mind.