Video instructions and help with filling out and completing How Form 2220 Toggle

Instructions and Help about How Form 2220 Toggle

Okay now let's add a toggle button to our form so a toggle button looks like this it's just it just looks like that it's a button and let's uh change this let's change some properties on this toggle button so I'm going to call this the name of em I'm gonna change your name to toggle button underscore model on/off let's say you're your work at some company and you're doing some calculations some mathematical calculation and as part of as part of the calculation you can either have one you can have a setting for something to be on or off and I won't even do the model I'll just put toggle button on/off and let's change the caption to on let's change the back color to something like blue let's change the font down here to something like bold and 24 and I guess I should make the text something a little bit more meaningful than just on let's do mata line let me change the font a little bit so all the toggle button is like a true/false it's like a switch and you either want the switch on or you want to switch off and I you know this is a very generic example let me move this down here and let's run this now so when I run it watch what happens when I click the toggle button it looks like it's depressed you could tell that it's clicked you know you see the difference in coloring that's all a toggle button does you get the idea that it's sort of like just an on-off switch so what we can do is do something like this let's double click this double click the toggle button and we'll do something like this if toggle button on/off dot value is equal to model on then else and if what we want to do is when you click the toggle button I want to tell you if the model is on or off so if you click it and the value is on then I'm going to loops I'm going to do this dot caption I'm going to change the caption to say model is off and if you click it when the value is off then I'm going to change the caption to say the model is now on so now let's run this again and see what happens when I click it I see what's happening let me double-click this the value of the toggle button is either true or false it's not it's not the text of the caption so if the value is true that means you pressed it I'm going to say the model is off else it's going to be on let's see if we run this if I run it you see what's happening now when I click it the caption is changing model on model off model on model off model on might alive so by default it pops up the model is on whatever the model is like some and I guess I shouldn't call it model let me change it to switch switch off switch on go up here change the caption to so which on so if the value is true that means if the value is pressed then change the caption to say switch off and that's what I'm going to put in comments here if the toggle is pressed change the to switch off I should put depressed that means it's like pressed in and if the toggle is on pressed change it to switch on so I can go to my worksheet now and go switch on/off and go into going to the code for the button and do something like this I can do cells X row comma 7 value is you go to toggle button underscore on/off but here I'm going to put that whatever the caption is so when we run this I'm going to put whatever this caption is on to the worksheet so if I run this now with like Jo and I'll put great and I'll put 125 pounds and I'll I'll press that down so that the switch is off and then I'll do enter data and close and notice the switch on/off column says switch off so that's all the toggle button is it's like a switch like a light switch you either turn it on or you turn it off and and you could do things when it's turned on or off like when you double-click it you can write code and in this case I'm double clicked it and I got into this toggle on/off underscore click that allows me to write code when the toggle is clicked in this case I'm just changing the caption when it's clicked and then I'm putting that caption onto the worksheet so very straightforward the toggle button is not complex it's just an on-off switch in the next video we'll look at we'll add a picture to the user form and that's coming up