SetTempVar (1 Viewer)

grenee

Registered User.
Local time
Yesterday, 17:01
Joined
Mar 5, 2012
Messages
210
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:

grenee

Registered User.
Local time
Yesterday, 17:01
Joined
Mar 5, 2012
Messages
210
I understand and appreciate your admonition.
I will avoid it in the future.
 

grenee

Registered User.
Local time
Yesterday, 17:01
Joined
Mar 5, 2012
Messages
210
I apologize for my breach of the forum rules and would avoid such action in the future.
 

Gasman

Enthusiastic Amateur
Local time
Today, 01:01
Joined
Sep 21, 2011
Messages
14,310
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
 

moke123

AWF VIP
Local time
Yesterday, 20:01
Joined
Jan 11, 2013
Messages
3,920
try ...
Code:
Expression = [test1].[Value]

worked for me

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

Gasman

Enthusiastic Amateur
Local time
Today, 01:01
Joined
Sep 21, 2011
Messages
14,310
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.
 

grenee

Registered User.
Local time
Yesterday, 17:01
Joined
Mar 5, 2012
Messages
210
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.
 

Gasman

Enthusiastic Amateur
Local time
Today, 01:01
Joined
Sep 21, 2011
Messages
14,310
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?
 

moke123

AWF VIP
Local time
Yesterday, 20:01
Joined
Jan 11, 2013
Messages
3,920
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.
 

grenee

Registered User.
Local time
Yesterday, 17:01
Joined
Mar 5, 2012
Messages
210
Thanks for the help.

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

Users who are viewing this thread

Top Bottom