GPGeorge
George Hepworth
- Local time
- Today, 03:25
- Joined
- Nov 25, 2004
- Messages
- 3,294
Here's the chart in that reference:Here I go again, believing what Microsoft documentation says.
![]()
The description of the "value" argument to the TempVars.Add method says:
IF you can use other data types, great... but that isn't what is advertised. I like to avoid stretching the boundaries on things.
| Name | Required/Optional | Data type | Description |
|---|---|---|---|
| Name | Required | String | The name to use for the TempVar. |
| Value | Required | Variant | The value to store as a TempVar. This value must be a string expression or a numeric expression. Setting this argument to an object data type will result in a run-time error. |
Note that it states, in column three, which labeled "Data type", that the data type of the value in a TempVar is a variant, whereas the data type of its name is a string.
Tempvars accept strings or numerics as input, but it is stored as a variant. This is a problem in some cases, such as where I pass dates to them or booleans. My solution is converting values retrieved from TempVars to other datatypes as appropriate before using them.
I use the functions above to convert them as needed, e.g.
Code:
SELECT DT.diabetestestid,
DT.testdate,
DT.testtime,
DT.testtypeid,
DT.testtimeofdayid,
DT.testresult,
DT.comments,
tbldiabetestesttype.sortorder
FROM tbldiabetestests AS DT
INNER JOIN tbldiabetestesttype
ON DT.testtypeid = tbldiabetestesttype.diabetestesttypeid
WHERE DT.testdate >= Tempvarsdate("dtfromdate")
AND DT.testdate <= Tempvarsdate("dttodate") )
AND Iif(Tempvarslong("lngtesttypeid") = 0, 0, [DT].[testtypeid])
IN ( 0, Tempvarslong("lngtesttypeid") )
ORDER BY DT.testdate DESC, tbldiabetestesttype.sortorder;
This SQL has three TempVars, two dates and a long integer. I acknowledge that in many cases, an integer would work as well as a long integer.