TempVarls

VSolano

Registered User.
Local time
Today, 09:00
Joined
Feb 21, 2017
Messages
92
Hi All

Can I use the value of a Tempvars as a column value in a query
 
Last edited:
You can use them about anywhere you would put an expression. For example if you set a tempvar like:

Code:
Dim SomeTempValue As TempVar
TempVars!SomeTempValue = "Something"

You could later use that in a query as an expression for example

Code:
SELECT [TempVars]![SomeTempValue] AS A;
 
Thanks Steve for the information

I have a date value in the tempvars that I want to place in a column for a calculation and I try this and it does not work.

I just create a new query with your information and the column does not return any value
 
This should work. Could you upload your database and tell me where you are creating and setting the TempVar in it.
 
I have the TempVars under a textbox from a from. I am entering the date on the form and I want to pull this date in a query so I can process some calculation.

I follow your instructions and I create a new query to I can see the value by itself and I does not return anything
 
I don't know what having the TempVars under a textbox from a from means. Please show us the code that is assigning the textbox value to the TempVar.

But if the form is open when you run the query I wouldn't use a TempVar but instead a reference to the textbox directly in the calculation. Let's say you wanted to add the field named Tax to the amount in the textbox named txtAmount in a form named frmMain then the expression would be

Code:
Total: [Tax] + Forms![frmMain]![txtAmount]
 
This is the code. TxtRecDate is formatted as short date


Private Sub btxopen_Click()
Dim RecDates As TempVars
TempVars!RecDates = Me.txtRecDate.Value
Me.Text3.Requery
MsgBox ("<<<" & TempVars!RecDates)


End Sub
 
Last edited:
A date won't show up in a query expression without first being converted to a string. You can see in the attached database that it shows up when you use CStr like:
Code:
SELECT Table1.ID, Table1.F1, CStr([TempVars]![RecDates]) AS Exp
FROM Table1;
 

Attachments

Users who are viewing this thread

Back
Top Bottom