"AutoKeys" in a library database?

DataMiner

Registered User.
Local time
Today, 14:10
Joined
Jul 26, 2001
Messages
336
Hi,
I want to have something similar to an "autokeys" macro in a library database that a bunch of other databases reference. This would just be a convenience to keep me from needing to copy the same autokeys macro to each database I create.

For example, I would like to set up so that
"ctl-h" always turns off the hourglass
"ctl-s" always clears the text in the status bar
etc.

But, as far as I can tell, macros in my library database are not accessible to my other databases.

Is there a VB equivalent to AutoKeys? Or does anyone have another approach to this?

Thanks a bunch for any suggestions you can offer!
 
You can set a reference to your "library" db but I would not recommend that. It is a very simple task to import your AutoKeys macro into your db's. I suspect that you are having other problems and/or you are not trapping your runtime errors to "reset" your display options if you need a macro to turn off the hour glass and to clear the status bar text [as you mentioned above]. Are you using VBA or just macros? The AutoKeys and AutoExec are about the only two macros that should ever be in a db. You should be using VBA instead [if you are not already]. Error handling is just one of the many reasons that macros are too limited versus VBA.
 
Last edited:
ghudson said:
You can set a reference to your "library" db but I would not recommend that. It is a very simple task to import your AutoKeys macro into your db's. I suspect that you are having other problems and/or you are not trapping your runtime errors to "reset" your display options if you need a macro to turn off the hour glass and to clear the status bar text [as you mentioned above]. Are you using VBA or just macros? The AutoKeys and AutoExec are about the only two macros that should ever be in a db. You should be using VBA instead [if you are not already]. Error handling is just one of the many reasons that macros are too limited versus VBA.

Oh, believe me, I'm using miles and miles of VBA code, in about a dozen different front-ends all in a nearly constant state of development. So.... my error handling is sometimes :rolleyes: imperfect.

I already have a centralized library database with dozens of custom functions which all of my frontends reference. This is very helpful and I'm puzzled as to why you "would not recommend that"....?

Anyway, I was just hoping there was some way to add custom shortcut keys to my library database, which would automatically then become available in all the frontends which reference it. Yes, I can certainly import the autokeys macro into each frontend, but this can become pretty inconvenient given the number of frontends I'm supporting

Sure seems like there should be some way to do the "autokeys" thing strictly from a VB function, skipping the macro....
 
Oops. My IE has been crashing randomly so I've been writing things in notepad and then copying them in their appropriate message. Wrong one. I do believe I found the VB equivilent though. Please hold. :p
 
Last edited:
Hm, I thought I saw the code earlier today.. but it appears I am either confusing the code for some other code or the code I saw was not workable since I have came across this note.

Also, are you using macros (instead of VBA)? This is a big no-no, especially in networked apps. Macros are generally slower, are much more of a pain to troubleshoot, and - most importantly - you can't trap errors in macros. Most experienced programmers (and your colleagues with 10+ years of Access experience should know this) use macros only for areas that cannot be addressed by VBA (like menus, Autokeys, etc).

I suppose you have tried to convert the macro to VBA already, eh?
Why can't you replicate your self-created AutoKeys macro into your other databases?
 
Last edited:
o1110010 said:
Hm, I thought I saw the code earlier today.. but it appears I am either confusing the code for some other code or the code I saw was not workable since I have came across this note.



I suppose you have tried to convert the macro to VBA already, eh?
Why can't you replicate your self-created AutoKeys macro into your other databases?


No, I haven't tried converting my AutoKeys macro to VBA. How would I do this? That, I think, is the crux of my whole question. If I could convert it to VBA. If I could convert it to VBA then I could put it in my library database and not have to replicate it in each individual front-end.

Yes, I can certainly replicate the AutoKeys macro.... what's keeping me from doing that is just pure STUBBORNNESS! :mad: There ought to be a better way! I certainly don't replicate any of the other custom functions I've created; what a pain if I had to remember to update them in a dozen different places every time I made a change!
 
DataMiner said:
No, I haven't tried converting my AutoKeys macro to VBA. How would I do this? That, I think, is the crux of my whole question. If I could convert it to VBA.

Yeah, you've stumbled across the biggest reason why I like C/C++ over VBA. You can easily include any previously devised code in .cpp file with one simple #include statement.

Anyways, I'm not positive if this will work with the AutoKeys macro but you can give it a shot. 1) Open Access, 2) Highlight the AutoKeys macro 3) Click Tools -> Goto Macro -> Click Convert Macro to Visual Basic 4) OK.

If it works, tell us! :)

Good luck.
 
Nahh, running the "convert macro to visual basic" thing just creates a function for each line in your Autokeys macro. For example, if you have a line using ^M to run MyFunction, "convert macro to visual basic" just creates a function named "AutoKeys__M" which runs MyFunction. But this doesn't make any shortcut keys work.
 
Found this at
http://www.microsoft.com/accessdev/articles/bapp97/chapters/ba02_1.htm

Why Use Macros?
After reading all the reasons for using Visual Basic, you may wonder if there are any reasons left for using macros. However, macros do have their place in many applications. Macros are an easy way to take care of simple details such as opening and closing forms, showing and hiding toolbars, and running reports. Because you specify options for each action in the lower part of the Macro window, there's little syntax to remember, and developing applications can often be faster than with Visual Basic.

In addition to the ease of use macros provide, creating a macro is the only way to make global key assignments.


See Also For information on assigning keys with an AutoKeys macro, see Chapter 1, "Creating an Application."


:(

So, I guess I am giving up the search for now. :(
 

Users who are viewing this thread

Back
Top Bottom