Using the On Click Event in Microsoft Access to Increment a Date Field by One Day.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to another tech help video brought to you by accesslearningzone.com i am your instructor richard rost in today's video i'm going to show you how to use the on click event to make a label that changes a date field see these little guys right here plus one plus one plus one right minus one all right you can use this for appointments or any other kind of date field today's question comes from anderson from buffalo new york my old stomping grounds one of my platinum members anderson says is there a way that i could click a button to move someone's appointment date forward one day and that should be a question usually i catch those but i just copied and pasted this from his email sorry anderson watch your grammar okay this happens a lot in our office and i'm sick of having to click on the field type in a value or click on the little pop-up calendar and click on the date there's a lot of steps involved in changing a date i know i just want one click and it's done okay okay so let's see how this works here here's a copy of my tech help free template this is a free download from my website go grab a copy if you'd like on here i've got a customer form and i've got a customer sense but let's pretend this is their appointment date all right so we'll just use customer sense and there's already a date field there now this is going to involve one line of programming so if you haven't watched my intro to vb video go watch it right now it's free it teaches you all the basics of getting into vba programming it's not hard all right go watch that lesson now if you've never done the vba programming then come back now these buttons right here that i've created before okay these use something called an on click event okay when you click on this button it opens this form and there's an event that happens when you click on it there's an event that happens when you click on these fields too but there's nothing assigned to that right now so let's see where that event is right click design view okay open up the properties for the orders button for example and you'll see right here it says on click under the event tab on click there's on double click there's on got focus that's what happens when you tab to this or click on a field for example the on got focus on lost focus when you leave a field there's all kinds of stuff you can do okay on click is the one you want on click says when i click on this object whether it's a button or a text box or any of that stuff do some stuff what's the stuff that you do well event procedure means we got some vba code so click on the dot dot button all right and in here there's already some code i built this in a previous video right it's do command open form that just opens up the order form for the current customer okay and i explained this in a template video but let's do something else let's do something from scratch so ignore these buttons for now in fact i'm going to take these buttons i'm going to move them over here get them out of the way pretend these don't exist all right let me teach you those are different sizes aren't they i don't even catch that okay let's see how we can make a little button to change the date in the customer sense field i want to move it ahead one day all right just like anderson wants to so come up top on the design tab find a command button right there button they used to call it command button now it's just button drop it there and we're going to cancel the wizard okay what we want to do isn't in the wizard love the wizard does some great stuff but it doesn't do this let's change the caption right plus one all right that's just the caption in the button itself okay we'll slide that right there next to customer sense okay now it's called command 30 right now axis just gives it a name command 30. let's change this let's give it a good name let's call this plus one day btn for button all right give it a good name go to events go to on click and hit the dot dot dot button or or on click is the default event you can just right click on the button and come up to build event it's way up top here off the screen build event now if you haven't watched my intro to vba video which you should have by now then you might get a window up that says what builder do you want pick the code builder that makes sure that you get the visual basic window all right and i'm right inside here in the plus one day button underscore click this is the on click event for this button all right what do i want to do in here well it's very simple i want to increase the date of the customer sense field by one day now remember dates in access work like this one equals one day so if you want to increase it a week plus it by seven or add seven to it plus it by seven i sound like a third grader right so i'm gonna say customer sense equals customer sense plus one that's it remember i said this required one line of code that's it one line of code one you just gotta know where to put the line of code and how to get there once you know how to do it it's simple okay save it close this all right close down the properties close down the form open it back up again and watch this click click click click click click click click click click click click click click click see anderson nice and easy right now you don't have to click on this hit the little where'd it go hit the little account oh see the calendar there it goes sometimes that calendar there's another object here that little calendar guy that pop-up hides but it's still there right then you got to come down here and click on that right this is so much easier and notice it's still it's still there it still exists there you could turn that off by the way if that's a problem double click on this guy go to format find show date picker and then turn it off never all right if you've got your own little button here because that date picker actually pops up there and it's kind of being obscured by our button so i don't i honestly don't like that date picker to be honest with you i don't use it a lot i have my own that i built it's on my website i'll put a link to it down below if you guys are interested i've got one also that you can pop up the time to shameless advertising plug here's my date picker all right looks a lot better you click on a field you hit select date this thing pops up and here's my time picker same thing but for times right you click a button this pops up you can click on 11 55 a.m if you want to okay i'll put links to the stuff down below okay advertising done for now let's say you don't want to use a button though let's say you want something a little fancier or you got a lot of stuff you want to put on here and you don't want to clutter it all up with buttons let's get rid of this button delete let's use a little teeny tiny label i like to do this trick this is one of my favorite tricks find a label in here click right there and go plus one that's it okay let's make it um let's make it blue like that all right and just make it as small as we can but still fit right next to it there you go okay open up its properties go to all let's give it a name plus one day label all right anything that i'm going to put code in or refer to i like to give it a good name all right my buddy alex taught me that one because i usually just leave it as command 15 because i wasn't going to refer to it anywhere else but it's better to name your stuff okay on click event dot dot dot now we're right in here now we got rid of this button so we can actually delete this code but first i'm going to steal that copy and paste it right in there and now we can delete the button stuff because i deleted the button when you delete an object like a button it doesn't delete any associated code with it so you got to be aware of that when you're programming okay save it close it open it back up again and look at that little tiny plus one there click click click does the same thing see that's because an on click event is associated with that label okay you can associate them with fields themselves in fact i like to use a double click event i got a video coming up on on double click i'll show you how to do that we could just double click here on the field and that will increase the the date in there that way you don't have to have the labels everywhere but the labels are good if you want to go plus one uh day plus one week in fact i'm going to show that in the extended cut for the members we'll make little buttons here for plus a day plus a week minus a week plus a month plus a year okay you can have little little values in here and one more thing i am going to note because i know some of you will get tripped up on this one if you look at the properties for a label and you don't see any events in here that's because you can't tie events to labels that are bound to a text box all right notice if i click on this guy and drag it it moves the text box with it see that's because these two are bound together all right if you want to assign a label an event you have to make it unbound so if let's say for example i want to assign a label to family size just cut it and then paste it again it'll come up up here but it's not associated with that text box anymore whoops all right right there see that and now it's got events oops come back here see now i can put events in there if it's associated with the text box it won't take events all right i get asked that a lot too okay wanna add another one for minus one right real quick just copy paste this guy all right i'm gonna slide plus one over we'll put minus one on the left all right we'll make this one minus one like that all right that's what is this guy called that's plus one day label let's make this one minus one day label whoops that's the on click event i messed up there see i even i goof up right cut that out of there go to all paste that in the name okay that should be the name of it the event is going to be dot dot dot now i'm in the minus one day label click right customer sense equals customer sense minus one save it close it close it open it ready go minus minus minus minus minus plus plus plus there you go there's your on click event want to learn more with the on click event and some vba well in the extended cut for members i'll show you how to make this combo box here where you can pick the interval so day week month quarter year you want to add six months you drop it down you pick month you click plus one plus one plus one six times i'll show you how to make it a function too so you can pass any value you want to it if you want to add a six there you can make it add six months right two clicks you're done so that's in the extended cut for members as a reminder silver members and up get access to all of my extended cut videos and there's a lot of them now how do you become a member click the join button below the video after you click the join button you'll see a list of all the different types of membership levels that are available silver members and up will get access to all the extended cut tech help videos live video and chat sessions and more gold members get access to a download folder containing all the sample databases that i build in my tech help videos plus my code vault where i keep tons of different functions that i use platinum members get all the previous perks plus access to my full beginner courses and some of my expert courses these are the full-length courses found on my website and not just for access i also teach word excel visual basic asp and lots more but don't worry these free tech help videos are going to keep coming as long as you keep watching them i'll keep making more if you like this video please give me a thumbs up and feel free to post any comments that you have i do read them all make sure you subscribe to my channel which is completely free and click the bell icon and select all to receive notifications when new videos are posted click on the show more link below the video to find additional resources and links you'll see a list of other videos additional information related to the current topic free lessons and lots more youtube no longer sends out email notifications when new videos are posted so if you'd like to get an email every time i post a new video click on the link to join my mailing list now if you have not yet tried my free access level one course check it out now it covers all the basics of building databases with access it's over three hours long you can find it on my website or on my youtube channel and if you like level one level two is just one dollar and it's also free for all members of my youtube channel at any level want to have your question answered in a video just like this one visit my tech help page and you can send me your question there click here to watch my free access beginner level one course more of my tech help videos or to subscribe to my channel thanks for watching this video from accesslearningzone.com
Info
Channel: Computer Learning Zone
Views: 2,260
Rating: 4.9365077 out of 5
Keywords: microsoft access, ms access, #msaccess, #microsoftaccess, #help, #howto, #tutorial, #instruction, #learn, #lesson, #training, #database, onclick property, click event, label doesn't have events available, command button, label, trigger, vba, event procedures, button click event
Id: NZVzBrCNYno
Channel Id: undefined
Length: 12min 45sec (765 seconds)
Published: Mon Feb 15 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.