Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Big Button Form 6 < Big Button Form 5 | Accidental Clicks >
Back to Big Button Form 6    Comments List
Pinned    Upload Images   Link   Email  
Transcript
Richard Rost 
            
5 months ago
This is part six of my big button forum series. If you haven't watched parts one through five yet, go watch those first and then come on back. All right, we're getting there. We're getting close to the wire here.

The problem we have next is what if the user wants to cancel. They pick this and they pick GMC and then they're like, oh, never mind. If they close this, it's still got that temp bar with the button return ID in it. So it's just going to use that and then return an invalid value. So what we're going to do is we're going to control whether or not the user can cancel that.

Because right now, they can just close the form. We want to prevent them from doing that and give them their own cancel button that we control. I don't like using any of the form close events; they're all weird. So let's go into our button. I'll copy one of these guys, copy, paste.

Is it possible to resize this form to fit the number of buttons? Yeah, it's possible. And like I said, it requires some math and some calculations of where stuff is, but it can be done. I've done it before. I think I even have videos on how to do it. But if you guys want to see how to do that, let me know. If enough people say yeah, I'll make another video about it.

We'll make this the cancel button, so put in here cancel. And you can bold it if you want to, whatever. Over here on the other tab, let's set the cancel property to yes. That way when the user hits escape, it pushes that button. That's what that does. Let's make the name cancel. Oops, hang on. That was over there. Over here. Cancel button, BTN, and it will have inherited this button clicked because I copied it from one of the other buttons. That's fine.

Let's just set its tag, where are you? Let's set its tag equal to zero. So this button will always return a zero to whoever called it. That way it will just say if the return value is zero, you're done, exit sub. Save that, close it, come into here now, right-click, build event. Now, in here, we'll just look at the return value and we'll say, if the make ID equals zero, then exit sub.

That's the easiest way to handle that. If the user hits cancel, you're done. Copy, oh, I forgot one more thing in the form. Put it there and put it here. One more thing I forgot about that form. Let's go back to the button form. Right click, design view.

We have to turn off the, where are you? You guys know what I'm talking about. The control box and the close button. The only way to get out of here is to click R button. Oh, and, oh yeah, no, never mind. The function handles that. I've done what, four of these in a row today, folks? I'm getting a little, you know, I don't know. Okay, so save it, close it, close it. Needless to say, this will be the last one for today. All right, so customer form, click the button, let's go Jeep, and then, oh, wait a minute, it's not visible. We didn't make it visible, did we?

All right, so we can, because we're the developer, we can right click design view, and see this is one of the problems I have. Right click, design view, and it, see, it just behaves weird. Make sure you set this guy so it's always visible. Visible, yes, there we go. I knew I forgot a step. See, I told you I'm getting tired. Alright, here we go, ready? Select vehicle, and there's our cancel. We can just cancel right away. It sends back a zero and nothing's put in there.

Customer, for example, click Chevy, uh... now they are a cancel and and it doesn't win it no current record what happened yet some all all all yeah and i know i did close this go back to the button code and area of this is the but don't go back to the customer form and can anybody see the mistake that i made let me make this a little bit bigger and if you take a look at it right now, can you see the goof that I made? I see it immediately because I got that error message before and I know exactly what I did. Pause the video and see if you could figure out what the problem is. I'll give you a hint. The cancel worked if I clicked it on the first form. If I clicked it when I was picking the make, it worked, but it didn't work for model linear. Do you see it? Pause the video, figure it out. All right, you ready for the answer?

This happens a lot when you copy and paste stuff. All right, this works, so I copied it, pasted it, pasted it, but I forgot to change the variable name. So this is looking at make ID up here, so we just got to do this. Copy, paste, copy, paste. Now it should work. Debug compile, back over here, hit the button, Jeep, cancel and it works.

That was my fault. That's a good learning lesson. I do that a lot folks. I copy some stuff, I copy a block of code, forget to change all the variables. I did it work the first time but now it's not working. And that's another reason why I don't like copying blocks of code, like the code in here. I don't like this. I don't like having basically the same thing three times in a row.

And what we're going to do in the extended cut for the members, this is my prototype database, the one I built before I recorded. What we're going to do in here is we're going to make a function out of it, just like this. We're going to make a function called openBigButtonForm. So we don't have a lot of repeated code. OpenBigButtonForm is going to handle all that. It's going to take parameters. So we'll send parameters in, the record source, the ID field name, the text button name, the where condition, the colors.

We'll add different colors. All right, so when we get to that, what you can do is you'll see it work like this. There's that. Model's green. Yours purple. We're going to do that in the extended cut. We're not there yet, though. We've still got a couple more things to do. Let's handle the no data error that we ran into earlier. Remember what I did when I went to the make table and I put BMW in there? But there's no BMW models in here. There's no 20 models. So if I go in here and hit BMW, we get this message. OK, how do we fix that?

Well, we could use error handling, like an on error go to or whatever. That's kind of cheesy for this, because there's a proper way to do it. We could use a D count or a D lookup and make sure there's records. But the proper way to do it is just to see if when you open the record set, if you are immediately at the end of file, that's the best way to do it.

All right, so before we even check the number of records, we're going to make sure there are records. Make sure there are records. So we're going to say if rs.eof, end of file, then message box, error, no records found. And then we'll do our force exit equals true. Else, now we can do this whole block, because we've still got to close everything up. We've opened a record set, so tab that in and then throw another end if down here.

This is why tabbing is important, folks. Tabbing your indentation is important, that way you can click here and look and see what you're directly under, all right? I see a lot of people sending me emails and posting stuff on my forums that they share a sample of their code and just because they didn't indent right they can't tell that this isn't under that. You know what I'm saying? I know it's stylistic. Access VB doesn't care about your indentations at all. Just like it doesn't care about your comments. This is all for you and it makes your code more readable. Another thing we want to do while we're in here is if we are force exiting, we want to also return that. If a force exit is needed, return that cancel.

Okay, save it. I moved this up so you could see more code. Debug compile, come back out, close it, close it, open her up, and pick BMW, no records found, and we're done. Okay. That's basically it. You have a working database now and if you're a gold member you can grab a copy of this. That's all you need. Right? That's it's functional. It works. It covers pretty much all the errors I can think of. Now in the extended cut we're going to cover a lot more. We're going to work on colors. We're going to make them pretty, okay? And more importantly, we're going to build a custom function. We're going to build a function called Open Big Button Form.

This way, when you go to use this in the future, you don't have to worry about setting temp bars and this and that. All you got to do is know the parameters. Here they are right here, Open Big Button Form. I can click in here. I send it the table, I send it the ID, I send it the caption name, whatever you want the caption of the button to be. The where condition, and if you click in here, you'll see what the things are. The where condition, the form caption, we've parameterized it all. There's the title up top, here's your colors. The form caption colors and all that. That's a green one, that's a purple one. To make another button after that, you just literally just copy this and just change those values. You don't got to set tempers, you don't got to worry about all that stuff. It makes it nice and easy for everybody to use.

And by everybody, I mean you. Because this is a developer tool. This is to make your job easier the next time you want to go make a big button form thing. You want to add engine down here or something else? Okay, so this is covered in the extended cut for the members. Silver members and up get access to all of my extended cut videos. There's lots of them, there's hundreds of them folks. So it's well worth your membership. And gold members can access the code vault where a lot of my cool functions are found. And you get to download these videos that I build in the TechHelp. And everybody gets free classes, all the members. You get a free class once a month. So check it out on my website. You'll find links to all this down below. Click that blue join button today if you want to become a member.

But that's going to do it for now folks. That's the end of this series for now. I got a feeling that I'm going to get a lot of emails and suggestions on the website forums for people that want to see some additional stuff. I actually put together a list of possible more stuff that we could add to this and if we do I'll either make another video or I'll put together a template for it, but lots of stuff like pagination of the buttons, multi-select options, there's all kinds of stuff we could do with this. This is just some of the stuff I came up with and a few suggestions that were sent in to me. So we'll see. We'll see. So will there be a part seven? Maybe possibly. I won't discount it. If so, I'll put a link down below. Make sure you're on my mailing list so you get my daily updates whenever I release new videos and you'll find out for sure. But that is going to be your TechHelp video for today. I hope you learned something. I hope you enjoyed the series. Live long and prosper my friends. I'll see you next time. A special thank you and shout out to our diamond sponsor Juan Soto with Access Experts software solutions. They're manufacturing experts specializing in Microsoft Access MVP. Check him out at accessexperts.com.



TOPICS:
Handling user cancel actions in forms  
Preventing form closure to control canceling  
Creating a custom cancel button  
Setting the cancel property for a button  
Ensuring cancel button visibility  
Setting button return values with tags  
Coding event actions for form buttons  
Disabling form control boxes and close buttons  
Troubleshooting common form issues  
Debugging and compiling VBA code errors  
Creating functions to reduce repetitive code  
Parameterizing functions for flexible usage  
Handling no data errors with record sets  
Using EOF (End of File) checks in VBA  
Implementing force exit logic in VBA  
Applying consistent code indentation and styling  
Creating a custom function 'OpenBigButtonForm'  
Parameterizing button form properties  
Enhancing user interface with custom colors  
Using DCount or DLookup for record checking

COMMERCIAL:
In today's video, we're tackling how to manage user cancel actions in your big button forum. First, we'll control the cancellation process to avoid returning invalid values. I'll walk you through creating a dedicated cancel button and its configuration so users can't just close the form. Then, we'll ensure the form fits the number of buttons, setting properties and visibility correctly. Learn common pitfalls like misnamed variables and how to handle no-data errors gracefully. You'll find the complete video on my YouTube channel and on my website at the link shown. Live long and prosper my friends.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Big Button Form 6.
 

 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 12/14/2024 5:13:09 AM. PLT: 1s