Gasman
Enthusiastic Amateur
- Local time
- Today, 23:19
- Joined
- Sep 21, 2011
- Messages
- 17,020
@theDBguy
Mainly as I got it from your site.
I am trying to run a query to add this months dates to a table.
I have set up the From and To values using Tempvars, but when the function at https://www.accessmvp.com/thedbguy/codes.php?title=execqry gets them, it says it cannot find them in the query, on the line
I am passing in a query name, not a string.
So where am I going wrong please?
Query.
Immediate window
Mainly as I got it from your site.

I am trying to run a query to add this months dates to a table.
I have set up the From and To values using Tempvars, but when the function at https://www.accessmvp.com/thedbguy/codes.php?title=execqry gets them, it says it cannot find them in the query, on the line
Code:
prm.Value = Eval(prm.Name)
I am passing in a query name, not a string.
So where am I going wrong please?
Query.
Code:
PARAMETERS [Tempvars("dtFrom")] DateTime, [Tempvars("dtTo")] DateTime;
INSERT INTO tblDates ( StepsDate )
SELECT DateSerial([YearNo],[MonthNo],[DayNo]) AS Dates
FROM tblDay, tblMonth, tblYear
WHERE (((DateSerial([YearNo],[MonthNo],[DayNo])) Between Tempvars!DtFrom And Tempvars!dtTo) And ((IsDate([MonthNo] & "/" & [DayNo] & "/" & [YearNo]))<>False))
ORDER BY DateSerial([YearNo],[MonthNo],[DayNo]);
Immediate window
Code:
? eval(TempVars("dtFrom"))
7.05467372134039E-05
01/07/2025
? eval(TempVars("dtTo"))
2.18694885361552E-03
31/07/2025