SetTempVar

grenee

Registered User.
Local time
Today, 05:31
Joined
Mar 5, 2012
Messages
212
Good Day,

Can anyone show me how to the value of the tempVar to display its value rather than its name string.

I have a control 'text1' on a form when a button 'go' on the said form is press the macro assignes SetTempVar the of 'test1'

Then the next action is for a message box to display the tempVar Value; however it doesn't it displays the string 'test1'

This is my Macro code:

SetTempVar
. Name Year
. Expression = [test1]
Message box
. Message year
. Beep yes
. Type none
. Title
 
Last edited:
I understand and appreciate your admonition.
I will avoid it in the future.
 
I apologize for my breach of the forum rules and would avoid such action in the future.
 
Hmm,
I tried as well and it does the same for me, however the help states it should do otherwise?

SetTempVar Name: MyVar
Expression: InputBox("Enter a non-zero number.")

[TempVars]![MyVar]<>0 MsgBox Message: ="You entered " & [TempVars]![MyVar] & "."
Beep: Yes

Type: Information

RemoveTempVar Name: MyVar

It works fine in VBA though?

HTH

Code:
Sub testTempvar()

TempVars("test") = "Fred"
MsgBox TempVars("Test")

End Sub
 
try ...
Code:
Expression = [test1].[Value]

worked for me

edit: i also would suggest not using Year as it is a reserved word.
 
try ...
Code:
Expression = [test1].[Value]

worked for me

edit: i also would suggest not using Year as it is a reserved word.

The macro code I posted was from the Access help?
I also tried [TempVars].[test] as well as [Tempvars]![Test] and it still shows exactly that and not the value of Tempvars.

Happy I do not use Macros much, if at all.
 
Thanks. None of the explanations work.

I do use VBA and it works fine; however, I want to learn to use Macros because they have potential and can possibly significantly reduce coding.
 
Thanks. None of the explanations work.

because they have potential and can possibly significantly reduce coding.

I've only used them for a series of queries to run in a sequence and in the built in switchboard.
For them to be useful however, they have to work as intended?

Try posting on a MS forum and get an explanation as to why their help article does not do as it shows it should?
 
it may be that tempvars is a variant and is interpreting the field as a string. By adding the .value you assign the value of the control.
 
Thanks for the help.

The problem is that I was missing the = sign in the message box
 

Users who are viewing this thread

Back
Top Bottom