remove first the NoData event, but test the HasData value:
Private Sub Report_Open(Cancel As Integer)
Msgbox Me.HasData
' Cancel = (Me.HasData = 0) ' the report has nothing to show
' If Not Cancel Then
' MsgBox "It is projected there will be insufficient stock of one or more...
add this to the code:
...
...
'just open the report (if no data to print, it will not show up)
On Error Resume Next
DoCmd.OpenReport "Inventory_Warning_Pop_Up_Report", acViewReport
DoCmd.RunSQL "Delete * From [zz_onhand_temp]"
ok, maybe directly Open the report.
add code to your report's Open event to check if there are records to show.
if none just Cancel the report.
if there is, show your messagebox.
on your report Open Evernt:
Private Sub Report_Open(Cancel As Integer)
Cancel = (Me.HasData = 0) ' the report...
you can try moving the zz_onhand_temp table to the FE (each FE) or move it to another Backend.
i did look at your Inventory_Warning_Query, and Production_ID and Product_Code from zz_onhand_temp table is being linked.
so i think you only need to insert these 2 fields in your Insert Query code...
adding Index will speed up finding records on your table.
take this snippet code from your function:
'Get the last stocktake date and quantity for this product.
If Len(strAsOf) > 0 Then
strDateClause = " AND (StockTake_Date <= " & strAsOf & ")"
End If...