Link to home
Start Free TrialLog in
Avatar of LearningToProgram
LearningToProgram

asked on

Access 2007 tempvars losing its value

I've got an Access application that sets the current user when they log in to tempvars!currentuserid.
I've used the exact same form in other applications with no problem.
With this application, the value for tempvars!currentuserid goes null at some point after the user has successfully logged in. In other words, the value is set correctly for some period of time, and then it later (at some seemingly arbitrary point) loses it's value.
I've checked for the obvious things such as tempvars.remove, tempvars.removeall, and setting the value to something else but none of that is in the code. After it is set, there is no use of  tempvars!currentuserid except to get its value.
Can anyone think of what could cause this to happen?
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

I suspect you have unhandled errors somewhere in your code.  When the code fails you get a debug and break and that will reset your tempvars.

Make sure all your procedures/functions have correct error trapping...

Regards,

Bill
http://msdn.microsoft.com/en-us/library/office/bb257083%28v=office.12%29.aspx says
" If you do not remove a TempVar object, it will remain in memory until you close the database. "
debug-break should not remove it.

"growing pains" nice euphemism for MS screws up again?
BillDenver, the behavior you describe is true for global variables, but does not apply to TempVars.  TempVars values are retained after an unhandled error, debugging activity, and code being stopped.

I haven't seen TempVars values get cleared spontaneously during a session, so I'm with LSMConsulting that some code, somewhere, is clearing it.

To help narrow down when the value is getting cleared, try setting a Watch on the expression tempvars!currentuserid.

Hope this helps,
Armen