TempVars?

jeudi 2 avril 2015

Hello all,



So I have read through threads, such as this

http://ift.tt/1EL9INb

In regards to tempvars and what (if any) benefit they might have. The database I am working through uses these everywhere, in macros, in VBA, in queries, on forms, they are all over the place. But, I don't see why they are needed anywhere other than in macros. For example, say I have form 1 open and I want more details about the customer, so I click a button with VBA behind it to open form 2 to show that record:

docmd.openform "Form2"



Now I will either open the form using this code:

docmd.openform "Form2", acNormal,,"[ID]=" & Me.ID



OR, if I am using a variable that needs to hold its value throughout the DB, I have a table that houses these variables and code that will set or get the variable value:

docmd.openform "Form2", acNormal,,"[ID]=" & GetVarValue(NewClientID)



The database I am working with have this type of code:

TempVars!MyTempProjectID = [ID].Value

MyProjectID = TempVars!MyTempProjectID

docmd.openform "Form2", acNormal,,"[ID]=" & MyProjectID



This seems like a lot of unnecessary steps to me, but perhaps there is something I am overlooking? I feel it would be better to keep any variables that are meant to be global in a table so you can easily find the value source and description of what the variable is used for, but maybe there is a benefit to using the tempvars like this in VBA code?

TempVars?

0 commentaires:

Enregistrer un commentaire

Labels