Access 2003 macro problem

R

Ron Hinds

I've been developing with Access '97 for quite some time. But now that we've
moved all of our customers to Access 2003 I'm going to do all of the
development with that tool. I have a macro which worked great in '97. The
macro was invoked by using the keystroke combination Ctrl-E. In a macro
named Autokeys, the Macro Name is ^e and the action is the name of a Public
Sub in a Module. When invoked with Ctrl-E while the cursor was positioned on
the declaration line of a new Sub or Function (either in a Module or a
Form's Class Module, etc.) it would create a skeleton declaring certain
variables and defining the error handler, etc., like so:

Public Function GetCouponCode(Invoice As Long) As String

On Error GoTo Error_GetCouponCode

Dim db As Database
Dim strSQL As String
Dim rs As Recordset

Set db = DBEngine(0)(0)

Exit_GetCouponCode:
Exit Function

Error_GetCouponCode:
msgbox Error, vbCritical, "Error " & err & " - GetCouponCode"
Resume Exit_GetCouponCode

End Function

When I try to invoke the macro with Ctrl-E in Access 2003, an Export File
dialog pops up. Fine, I thought, just a conflict wiht that key combination,
so I changed the Maro Name to ^+e, which should change the keystroke to
Ctrl-Shift-E. Nothing happens when I type that keystroke in a module.
Interestingly, if I am in the main Access 2003 window, that keystroke *does*
invoke the function defined as the Action for the macro, but with disastrous
results since I'm not in a Code Window. It seems that now that the Code
"Window" is actually a separate process, it is ignorant of any macros
defined in the main access window. So, how do I define a macro that works in
the Code process? I've tried using the Help system to find out, but,
frankly, the new Help system SUCKS (that's for another post)!
 
D

david12

I've been developing withAccess'97 for quite some time. But now that we've
moved all of our customers toAccess2003 I'm going to do all of the
development with that tool. I have a macro which worked great in '97. The
macro was invoked by using the keystroke combination Ctrl-E. In a macro
named Autokeys, the Macro Name is ^e and the action is the name of a Public
Sub in a Module. When invoked with Ctrl-E while the cursor was positioned on
the declaration line of a new Sub or Function (either in a Module or a
Form's Class Module, etc.) it would create a skeleton declaring certain
variables and defining the error handler, etc., like so:

Public Function GetCouponCode(Invoice As Long) As String

On Error GoTo Error_GetCouponCode

Dim db As Database
Dim strSQL As String
Dim rs As Recordset

Set db = DBEngine(0)(0)

Exit_GetCouponCode:
Exit Function

Error_GetCouponCode:
msgbox Error, vbCritical, "Error " & err & " - GetCouponCode"
Resume Exit_GetCouponCode

End Function

When I try to invoke the macro with Ctrl-E inAccess2003, an Export File
dialog pops up. Fine, I thought, just a conflict wiht that key combination,
so I changed the Maro Name to ^+e, which should change the keystroke to
Ctrl-Shift-E. Nothing happens when I type that keystroke in a module.
Interestingly, if I am in the mainAccess2003 window, that keystroke *does*
invoke the function defined as the Action for the macro, but with disastrous
results since I'm not in a Code Window. It seems that now that the Code
"Window" is actually a separate process, it is ignorant of any macros
defined in the mainaccesswindow. So, how do I define a macro that works in
the Code process? I've tried using the Help system to find out, but,
frankly, the new Help system SUCKS (that's for another post)!

Access 97 included modules and VBA Editor as part of Access. One of
the major changes for Access2000 was that the VBA editor is a separate
program from Access and does not respond to macros in Access.
Best thing I can think of is to have your code "template" easily
available somewhere for copy-pasting to start a new procedure.
Sorry.
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top