I have a after update event on a field that takes approx 15 - 20 seconds to run, The event code is below.
Is there any way to let the code run in the background without the user having to wait for this code to run ?
I used to run this as a append query overnight, but have had to stop that process.
I think the delay is down to the last 2 fields, which are in different tables. Cost price and Direct Price. If i remove these, the code runs in approx 5 seconds.
Any ideas welcome.
Is there any way to let the code run in the background without the user having to wait for this code to run ?
I used to run this as a append query overnight, but have had to stop that process.
I think the delay is down to the last 2 fields, which are in different tables. Cost price and Direct Price. If i remove these, the code runs in approx 5 seconds.
Any ideas welcome.
Code:
WarningsOff
strsql = "INSERT INTO tblQCProduct ( Line_No, Division, Department, Category, Sub_Category, Date_Added, Line_Description, Landed_cost, Direct_Price ) " & vbCrLf & _
"SELECT DISTINCT tblcatalog.Cat_No, tblcatalog.Division, tblcatalog.Department, tblcatalog.Category, tblcatalog.Sub_Category, Now() AS Date_Added, tblproducts.Line_Description, Max(tblcostprice.Cost_Price) AS MaxOfCost_Price, Max(tblDirectPrice.Direct_Price) AS MaxOfDirect_Price " & vbCrLf & _
"FROM ((tblcatalog INNER JOIN tblproducts ON tblcatalog.Cat_No = tblproducts.Cat_No) LEFT JOIN tblcostprice ON tblproducts.Option_No = tblcostprice.Option_No) LEFT JOIN tblDirectPrice ON tblproducts.Option_No = tblDirectPrice.Option_No " & vbCrLf & _
"GROUP BY tblcatalog.Cat_No, tblcatalog.Division, tblcatalog.Department, tblcatalog.Category, tblcatalog.Sub_Category, Now(), tblproducts.Line_Description " & vbCrLf & _
"HAVING (((tblcatalog.Cat_No)=[Forms]![frmMain]![tbCatNo]));"
Debug.Print strsql
DoCmd.RunSQL strsql
WarningsOn