I am creating a querydef that grabs everything from another query, applies a parameter and exports to excel. This worked fine for months until yesterday, when it started returning runtime error 3021 - no current record.
The error occurs on qdf.execute.
I have another database that is basically the exact same thing with the exact same code, this works fine.
I have tried to put the sql string into a new query manually, this also works fine.
Dim Dstring As Date
Dstring = asofdate
Set qdf = CurrentDb.CreateQueryDef("")
qdf.SQL = "SELECT * INTO WIP_Report FROM Qry_WIP_Percentage"
qdf.Parameters("AsofDate") = Dstring
qdf.Execute
There are about 900 records in the query, and the parameter is being applied.
this is the SQL from the query -
SELECT Left([Qry_WIP].[rollup],5) AS Parent, Qry_WIP.rollup AS [Shared Parent], " " AS [Previous Wip], Qry_WIP.WIP AS [Current WIP], Qry_WIP.[PO Price Summed] AS [PO Value], "" AS [Anticipated PO], " " AS [Previous Percent Complete], Qry_Percentage.Percentage AS [Current Percent Complete], Qry_WIP.[prod code], Qry_WIP.[cust-id], " " AS [Customer / Project], " " AS Notes, " " AS [Previous Amt to Recognize], " " AS [Previous Status], "" AS [Current Amt to Recognize], Qry_WIP.status AS [Current Status], Qry_WIP.[enter date]
FROM Qry_WIP LEFT JOIN Qry_Percentage ON Qry_WIP.rollup = Qry_Percentage.rollup
GROUP BY Left([Qry_WIP].[rollup],5), Qry_WIP.rollup, Qry_WIP.WIP, Qry_WIP.[PO Price Summed], Qry_Percentage.Percentage, Qry_WIP.[prod code], Qry_WIP.[cust-id], Qry_WIP.status, Qry_WIP.[enter date]
No clue what is happening here as it worked perfectly the other day.
I see there are a bunch of questions about no current record, however, those all appear to be for recordsets not a querydef.