Quote:
Originally Posted by lionelm2007
Hi there,
I have a form called Production Run and has a field to select a product. I would like to grab the recipe for a particular product from product recipe table, do some calculations on the fields and insert the most up to date recipe into another table called tblProductionRunUsage. I can then display the most up to date for each production run as a subform on the main production run form. The reason I am doing this to save the current product recipe for each production run as the product recipe changes often.
I have created an update query using the query wizard. This query will insert the most up to date product recipe for a particular production run into a table called tblProductionRunUsage.
I would like to run this query every time a production run record is added and a product is selected.
Does anyone know what is the code for this.
I have tried this:
DoCmd.OpenQuery "qryAppendToProductionRunUsage", acViewNormal, acReadOnly
It does not work. And when should I execute the query? After the user select the product? What if the user makes a mistake and chooses another product, then the insert operation will fail as it already exists in the tblProductionRunUsage.
Any help is greatly appreciated.
have you tried removing the acReadOnly off the end? Whether or not the query will fail depends on the table settings, i.e. whether it'll allow duplicates in the relevant fields. But in any case it sounds like you might want a facility where the user confirms their selection is ok, i.e. a confirm cmd button
HTH
Kevin