Forgive me as I try to be brief:
I am using a modified version of Allen Browne's excellent 'onhand' function for calculating stock levels 'on-the-fly'.
The function works perfectly, however I need to show stocklevels for a number of items on my 'home' form and found that the onhand function is way too slow to allow that. My solution is to 'reflect' the onhand results via a query into my products table, and this works well, since I'm simply viewing the data.
But when I perform a transaction, I can only get the onhand function to work if I recalculate all of my products, rather than just the ones in the transaction - and that is slow - at least 30 seconds.
I have tried my preferred method of SQL in the module code, and running a query of the same from the code, but zero records are updated. Here is the SQL I have been using - can you see an error?
Expand|Select|Wrap|Line Numbers
- Dim strSQL as String
- strSQL = "UPDATE Products SET Products.Stocklevel = (onhand([productID])) " & vbCrLf & _
- "WHERE (((Products.Stocklevel) = [forms]![frm_PurchaseDetails]![productID]));"
- DoCmd.SetWarnings False
- DoCmd.RunSQL(strSQL)
- DoCmd.SetWarnings True
If you don't know the 'onhand' function, you simply provide the ProductID and an optional date to get the stock calculation for that date.
The SQL for the query that works (but calculates all products) is;
Expand|Select|Wrap|Line Numbers
- UPDATE Products SET Products.Stocklevel = (onhand([productID]));
Sorry it appears so drawn out...
Best regards,
Stonward