Access 2010 TempVar

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome what I'm gonna go over here today is a thing called Templar and you can find that in your macros I'm using Access 2010 however here using 2007 or 2013 you should be able to follow along and temp are what is a temp thought it's a temporary variable and a temporary variable it's a way to store a piece of information and the background memory you've got the database and it'll stay in the background memory of a database until you do one of a couple of things you can either remove it with a another macro or you can close the database and when you close the database it's gonna empty all of its background memory so basically you take a piece of information you put it in a variable and it just hangs out in la-la-land and then you can refer back to it at any time you want so the link you go ahead and give you a brief example how this works I'm going to go ahead and drop a combo box on this form and I'm going to put a few names in here and let's go ahead and put in David sue and Mike and I'm single and click finish so basically this login form so when we select a name we're going to take that name when we're going to store it in the background memory as our current user and then we'll be able to refer back to our current user on other forms to customize how the form looks and reacts with that user so let's go ahead and save our changes we'll save it as form one and I'm going to open the form one and design view and we're going to go ahead and setup the variable so I'm going to select the combo box and we want the after update of it in other words when we select the name we want it to become our current user so I'll click on the ellipse we want the macro builder and we'll go to our list here there's a couple things in here and if you scroll down you'll see our item down here set temporary tent far and that's what we're going to be using you don't want to confuse that with a local bar they're both variables but they have different uses and I mentioned also that you can remove a temporary variable with another macro and this is how you would do it and if you clicked on it you would just the only thing that's going to ask you for is the name of the variable you want up Emotiv you can also remove all templars so that it's telling you that you can have several going in the background at the same time i think you can have up to 255 going at once but if you have that much stuff bouncing around in your background memory it's probably going to have a little bit of performance hit on your database so very useful just use them when you need them and if you need to use one for to do a couple tasks then turn it off there is a way to do that so that would be a good way to do it so let's go ahead and get started with ours we're gonna set a temporary variable once I click on it it's only going to ask us for a couple of things it's going to ask us for a name and in this case we're gonna call it C user and the second piece of information along it says well what are we going to store in it and we're gonna store whatever value will we select from the combo box so let's go ahead and click on our magic wand it's going to open up the expression builder make sure form 1 is selected and we want whatever's in our combo box so I'm going to double click on that and it's going to drop up here and the expression builder and at this point we're done I'll click OK close save our changes yes and then save the form now let's go to form view so now once we select name we've taken the name David and we've stored it in the background memory so when we close this form we can go back and refer to that temporary variable and get our value David and a quick example how that would work would be let's go ahead and drop a text box on here we're just gonna put the name of the current user in this text box so I'm going to select the text box I'm gonna go to my data tab and I am going to select default value and the default value is gonna equal whatever is in the temporary variable so it's going to be equal to far and you'll see that once I hit the tab key it's in square brackets so it's kind of like objects on the form and you put an exclamation mark open and close square brackets and then we'll put in the name of the variable see user and we're done so basically the default value of this text box is going to be whatever is in our variable so we're not referring back to the combo box we're actually referring the variable so I'm going to go ahead and save changes we'll call it form to go to view it and you'll see that David is currently logged on if I go back to form 1 and change our user you'll now see that Mike is logged on so let's go ahead and do one more thing you're going to drop a button on the form and it's not going to do anything so let's close that what I'm going to do is I'm a set the visible property of this button into you know in other words I'm going to turn it off so it's invisible and go to the form view and you can see the button is invisible now what we want to do is we want to make it so that this button becomes visible depending on what user is logged on so to do that I'm not gonna use the properties of the button I'm actually use the properties of the form so go ahead and select the form go over to the property sheet and because your form is selected we're gonna go to the event and we're going to use the armload of that click the ellipsis and we're going to build a macro click okay so when the form opens up the first thing we wanted to do is look in the temporary variable see who's logged on and if a certain person is logged on when we're going to trim the button line so we want an if statement what if mbar and the variable we're going to look in is going to be current user so if temp our current user equals well I'll put in a literal string here so we'll put a name in quotes and let's say let's see so if our temporary vary if our current user is su then we're going to turn the button on and to turn the button on we're going to add a new action we're going to go ahead and select our list we're gonna go down to you go set property and once we solutely select the set property it's gonna ask us or three things what control what property and what's the value so the control is the button we put on the form and that would be command - that's the name of the button the property is going to be the visible property and we don't want to change out from false to true other words right now it's off what we want to turn it on and in access - one is true and zero is false so we want true - one and we're done see if our changes let's go ahead save our form open it up you see bikes logged on so you can't see the button open up form one we'll login with soon series never a current user and if we open up form Tegel there's your button if we go ahead and log off and go to david form to now David's logged on you can't see the button so there you have it there's the tip of the iceberg for you temp bars very useful just use them sparingly so you don't kill your database hopefully you found this information useful thanks for watching and have a good day
Info
Channel: amorrill1000
Views: 13,813
Rating: 4.807229 out of 5
Keywords:
Id: 4jAVOEUlKbE
Channel Id: undefined
Length: 9min 28sec (568 seconds)
Published: Fri Apr 04 2014
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.