Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coding template? 1

Status
Not open for further replies.

Recordsetclown

Technical User
Jul 12, 2002
64
US
Is there a way to have Access supply the same sort of error handling code for event coding that is attached to a command button automatically by the wizard? I confess I don't always put in error handling code because I don't take the time to type it. It would be nice if I could just enter my operative code into a stock template containing that repetitive coding.
 
There are probably commercial development packages that facilitate this, but a simple and free method is to put your stock code in a personal library database and simply import the templates when you need them. You would rename the module and any procedures within it after import, of course.

You could also write your own wizards, but that's an advanced project. If you want to go in that direction, I'd recommend you get a Developer Edition of Access. It contains more controls and tools to help you out.

If you have the Access 97 Developer Edition, you got the book Building Applications with Microsoft Access 97 on the CD. It contains a fairly good chapter on writing wizards. Access 2000 Developer has an expanded version of this book under a different name, which I don't recall offhand. Rick Sprague
 
Thanks Rick,
I don't have Developer Edition but could do the library thing. This is the wrong forum, but I'm also wondering if it might be possible to code a small program in VB6 that would watch for the control name to enter the clipboard from Access and then plug that into the stock code and put the whole thing back in the clipboard where I could paste it into the event. Kind of roundabout.

Jeff
 
Your "TechnicalUser" identity threw me off. If you could do this in VB, a rudimentary add-in won't be too hard for you. You can hook the add-in up to a toolbar button and/or an AutoKeys macro.

First, study the Modules and Module objects to learn how to edit modules in code.

Then, create a separate database for your add-in and write code that prompts you for a control name or whatever, builds a procedure as a single string with embedded CrLf's, and puts it in a multiline text box on a form. That will give you a means of debugging the add-in. You can't actually write to a module while you're debugging, because editing a module in code interrupts the debugging interface, making it stop working for a while.

When you've got it working smoothly, you'll need to make changes so that it actually updates the currently open module in the database being developed, and create a USysRegInfo table so it can be loaded as an add-in. I need to leave for work right now, but I'll give more details later if you want to pursue this.

BTW, do you know how to write text parsing code? If you do, you could make your add-in fancier and more flexible. Rick Sprague
 
Actually, I've written code that does this for me. It's pretty nice, building in copyright, errorhandling, etc. I posted it once here, but I'm not sure where. I'll put it up on my website by tomorrow night, so that I don't have to keep doing the assembling of it and the write up.

If it's not up by Wednesday morning, send me an e-mail, and I'll get to it.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Ok, Recordsetclown, Jeremy has offered a pre-built package that probably has more bells and whistles in it, if you want to wait a day. I'd be able to post something simple late tonight. Should I go ahead, or do you want to wait for Jeremy? Rick Sprague
 
Rick,
Thanks very much for the overview. I would enjoy trying this just to learn how it's done, but there is no particular urgency. I'll look at Jeremy's site to see what he has canned and try to do an add-in on my own.

Jeremy,
Thanks for the offer.



 
Jeremy,
Thanks again. I finally had time to try your code yesterday and, after a bout or two of operator ignorance, have it working fine. Here's a star. Thanks also for pointing me to your site, which has lots of other interesting stuff as well.
Jeff
 
Jeff,

Thanks for the star, and I'm glad you find the site interesting.

Happy Coding.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top