Solved TempVar (1 Viewer)

Sarah.M

Member
Local time
Today, 19:24
Joined
Oct 28, 2021
Messages
300
Hi, Plz note, My VBA is blocked by IT for security reason (Cybersecurity).
I can use only Expression builder, Macros, Queries, Tables, Forms and Reports only.
----------------------------------------------
I want TempVar to Read text, from textbox but I got errors, I mark them by red color
With numbers it is working good but with text it does not work 😒 😖
How can I let Tempvar to read text?

plz hlep me to fix it 🙏

Sample attached
1654983452000.png
1654983486813.png


1654980134333.png
1654980115669.png
 

Attachments

  • TempVar.accdb
    608 KB · Views: 36
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 09:24
Joined
Oct 29, 2018
Messages
18,998
When using TempVars in VBA, it gives an error sometimes that it can't store objects, which is true. This happens because it sometimes requires the Value property in the assignment statement. Perhaps the same problem applies to macros as well.
 

Sarah.M

Member
Local time
Today, 19:24
Joined
Oct 28, 2021
Messages
300
When using TempVars in VBA, it gives an error sometimes that it can't store objects, which is true. This happens because it sometimes requires the Value property in the assignment statement. Perhaps the same problem applies to macros as well.
I apologize I did not understand.
Do you mean there is no solution؟
 

GPGeorge

Grover Park George
Local time
Today, 09:24
Joined
Nov 25, 2004
Messages
683
Try Tempvars!YourTempVarNameGoesHere.Value
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:24
Joined
Oct 29, 2018
Messages
18,998
I apologize I did not understand.
Do you mean there is no solution؟
Of course there is a solution. Sometimes, it is easier if you post the macro code rather than ask members to download your file and figure out which form you were talking about. Sometimes, I am on my phone and can't download files anyway.

If you're using SetTempVar, you might try using SetLocalVar first and then assign the value of the LocalVar to your TempVar.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:24
Joined
Feb 28, 2001
Messages
22,832
Might need quotes around the text arguments?

Error 2766 says that you are trying to exercise something via automation but there is something wrong with the attempt. When trying to store, say, an application object, that object doesn't have a .Value property because it isn't really a variable in the normal sense. It is a pointer to something that has LOTS of values - but qualified by where to find them. So you can't pull a .Value from most objects without a LOT more syntax to find your way by pointing to things with the object that DO have values.

To get that error, Access (and the TempVar) must think you are trying to give it something that inherently doesn't have a .Value, and I noted in the two pictures you gave us that your "arguments" were apparently not quoted. Which probably means that Access thought the text strings were variable names - which it cannot find. Which leads me to believe that error 2766 is the generic argument for "I don't understand that argument."
 

Sarah.M

Member
Local time
Today, 19:24
Joined
Oct 28, 2021
Messages
300
Might need quotes around the text arguments?

Error 2766 says that you are trying to exercise something via automation but there is something wrong with the attempt. When trying to store, say, an application object, that object doesn't have a .Value property because it isn't really a variable in the normal sense. It is a pointer to something that has LOTS of values - but qualified by where to find them. So you can't pull a .Value from most objects without a LOT more syntax to find your way by pointing to things with the object that DO have values.

To get that error, Access (and the TempVar) must think you are trying to give it something that inherently doesn't have a .Value, and I noted in the two pictures you gave us that your "arguments" were apparently not quoted. Which probably means that Access thought the text strings were variable names - which it cannot find. Which leads me to believe that error 2766 is the generic argument for "I don't understand that argument."
plz can you suggest to me a syntax to write
 

GPGeorge

Grover Park George
Local time
Today, 09:24
Joined
Nov 25, 2004
Messages
683
Might need quotes around the text arguments?

Error 2766 says that you are trying to exercise something via automation but there is something wrong with the attempt. When trying to store, say, an application object, that object doesn't have a .Value property because it isn't really a variable in the normal sense. It is a pointer to something that has LOTS of values - but qualified by where to find them. So you can't pull a .Value from most objects without a LOT more syntax to find your way by pointing to things with the object that DO have values.

To get that error, Access (and the TempVar) must think you are trying to give it something that inherently doesn't have a .Value, and I noted in the two pictures you gave us that your "arguments" were apparently not quoted. Which probably means that Access thought the text strings were variable names - which it cannot find. Which leads me to believe that error 2766 is the generic argument for "I don't understand that argument."
You're right. I was remembering it backwards. This is syntax in the code line I was referring to.

Call TempVarsValue(TempVarName:="dtShoppingDate", TempVarValue:=.cboShoppingDate.Value)

It requests the Value property of the control, not the tempvar.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:24
Joined
Feb 28, 2001
Messages
22,832
plz can you suggest to me a syntax to write

Believe it or not, I'm at a disadvantage here. I never use macros because I'm so comfortable with VBA. My guess - which seems to be supported by GPGeorge - is that when you have a text name to pass in to something, and you can't use a variable, you must use a literal value or constant - which for text, must be enclosed in quotes in order to not be mistaken for something else. My suggestion was based on general programming rules rather than any specific knowledge of macro syntax.

In your "IT lockdown" situation, you are pretty badly hampered. To be honest, I'm surprised that you've gotten this far, because the security of Windows (not of Access itself) should really be stopping the macros, too. I'm not trying to rain on your parade, here, but if it were me, I would be in the face of the IT guy for an explanation for why macros are allowed but VBA is not. But you have to run your situation your way, so ignore this old curmudgeon who doesn't put up with people who do things but can't give you a specific reason for what they do.
 

GPGeorge

Grover Park George
Local time
Today, 09:24
Joined
Nov 25, 2004
Messages
683
Believe it or not, I'm at a disadvantage here. I never use macros because I'm so comfortable with VBA. My guess - which seems to be supported by GPGeorge - is that when you have a text name to pass in to something, and you can't use a variable, you must use a literal value or constant - which for text, must be enclosed in quotes in order to not be mistaken for something else. My suggestion was based on general programming rules rather than any specific knowledge of macro syntax.

In your "IT lockdown" situation, you are pretty badly hampered.
To be honest, I'm surprised that you've gotten this far, because the security of Windows (not of Access itself) should really be stopping the macros, too. I'm not trying to rain on your parade, here, but if it were me, I would be in the face of the IT guy for an explanation for why macros are allowed but VBA is not. But you have to run your situation your way, so ignore this old curmudgeon who doesn't put up with people who do things but can't give you a specific reason for what they do.
I have to say, in a situation like that, I'd be spending an inappropriate amount of time updating my resume rather than this crippled Access relational database application.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:24
Joined
Feb 28, 2001
Messages
22,832
I have to say, in a situation like that, I'd be spending an inappropriate amount of time updating my resume rather than this crippled Access relational database application.

Can't say I would disagree, except that the one time this became an issue, I was able to talk to our IT guy by getting my boss engaged in the conversation. He was able to point out that the function being developed was desired (requested? DEMANDED?) by higher-ups. My boss asked the IT guy if he would like if it if my boss talked to his boss about inter-departmental cooperation. Not very long after that we were able to reach a comfortable compromise that, six weeks later, made the IT guy admit I had done pretty well in using some standard Navy security principles to assure proper security. He focused on someone else for a change and I got some work done. Sometimes, sadly, it isn't about knowing programming, but is more about the ability to navigate the hazards of politics when one of the participants has the unenviable job of stopping things from happening.
 

GPGeorge

Grover Park George
Local time
Today, 09:24
Joined
Nov 25, 2004
Messages
683
True that.

I have a similar, but much less formal, story. In one of the few really large corporations where I found myself working, I entered a similar situation with IT and the people in the department where I worked, they only grudging accepted Access and cooperated reluctantly on any request after lengthy hurdles were thrown in the way. On a personal level I finally just invited the DBA with whom I had to work for a cup of coffee. We got to know each other a little bit and share some common frustrations. It was enough to open a channel where we could discuss solutions to problems, rather than terse exchanges over process.

I refer to that as "the cuppa coffee approach" to IT. In some cases, others may prefer an adult beverage, after work hours, of course.

I guess resume burnishing should be a last resort.
 

Users who are viewing this thread

Top Bottom