[ACCESS 2007] Use VBA code instead of a macro

bodylojohn

Registered User.
Local time
Today, 14:21
Joined
Dec 28, 2005
Messages
205
Hello,

When I add a butten using the wizard Access 2007 adds a macro instead of vba code.
How can I get the good old VBA code???

Thanks for your help in advance
 
rightclick the button and choose "Build event"

change the access options: form/reports: "Always use event procedures"

HTH
 
Hello,

Thanks for the reply.
But I want to use the wizard.
In access 2003 the wizard wrote VBA code.
In access 2007 the wizard makes a macro.

But I want the wizard in access 2007 to generate VBA code...

I hope you guys can help me...
 
Click the wand button b4 you choose your control.
 
Click the wand button b4 you choose your control.

Hello Guus,

When I do that I dont get the code generated by the wizard.
This is something new in Access 2007. I just want the wizard to generate VBA code and not a macro.

How can I do that
 
I don't know what you are talking about because I have Access 2007 and if you have the wizard button clicked and then add a command button it brings up a wizard where you can choose what you want it to do. Then, following it through the wizard and then clicking FINISH gives code in the VBA IDE (not a macro) of:

Code:
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click


    DoCmd.RunCommand acCmdUndo

Exit_Command3_Click:
    Exit Sub

Err_Command3_Click:
    MsgBox Err.Description
    Resume Exit_Command3_Click
    
End Sub

That is a sample of what I get when using the wizard.
 
Do you have the database extension set to 2007 or 2002/2003?

Because when I have the database set to 2002/2003 whitin access 2007 I DO get VBA code when I use the wizard.
BUT when I set the extension to 2007 I get a macro.
 
Aha! NOW I see what you mean. Yep, it looks like we got screwed again. Apparently using the wizard will create an embedded macro for the operation. That definitely sucks. :mad:
 
Hi Bob,

Thanks for all of your replies.

I dont like being screwed. I just want the wizard to generate VBA code.
Is there realy no possibillity???
 
Hi Bob,

Thanks for all of your replies.

I dont like being screwed. I just want the wizard to generate VBA code.
Is there realy no possibillity???

You could create it in an Access 2000 database type and then copy it over to the A2K7 version. So, in other words, you create the control using the wizard in an A2K version and then in A2K7 click the control and place it on the form and then hit cancel when the wizard comes up. Then, manually go set the click event to EVENT PROCEDURE and click the elipsis (...) next to it and paste the code in from the A2K database.

Of course, what you can do is to create a code repository to be able to do some of the functions you normally use buttons for and use that to manually add it in without having to type it all over either.
 
Dear Bob,

Where can I find a good example of how to make such a code repository?

I want to learn how to do it myself.

Thanks...
 
What I do is to keep a text file on my computer with useful pieces of code in it. Then I can cut and paste them into the VBA editor as required. I think that is what Bob is suggesting
 

Users who are viewing this thread

Back
Top Bottom