Form button Code

TomUK

Registered User.
Local time
Today, 19:42
Joined
Dec 16, 2008
Messages
16
I am having trouble finding the VBA code behind a button placed on a form in Access 2007. I have placed a run query button on a form using the wizard. Using alt F11 I bring up VBA to view the code but I can’t find anything in VBA. I want to modify the code so I can get several commands on one button. I basically want to run a query and then open an excel spreadsheet with the data from that query exported to the excel spreadsheet. Any help you can give me with this is greatly appreciated.
 
In design mode, right click the control and go to properties. Switch to the Event tab and press the "..." button next to your event.
 
That takes me into Macro tools design tab.

I want to see the VBA code behind the form/button as what I want to do is not in the standard list of commands in the macro tools
 
If nothing has been defined yet then select the Code Builder after pushing the "..." button.
 
If you added a button, using the wizard, in 2007 it will not be using VBA code but will instead be using an Embedded Macro.
 
But you can use the DropDown next to the "..." button and select [Event Procedure] and then press the "..." button to create a code stub for the event.
 
But you can use the DropDown next to the "..." button and select [Event Procedure] and then press the "..." button to create a code stub for the event.

But if it has been added via the wizard it will use an embedded macro and not VBA. The OP wants to see the code behind the button to modify it, but it is not in code. It is an embedded macro. So, while setting it to [Event Procedure] will get you to the code window, it won't do a thing for you to view the "code" behind the button as it isn't code. But I don't ever add them using the wizard anymore in 2007 as I want my own code.
 
I just tried it and the code seems to *replace* the embedded macro.
 
Thanks for the replys.

You will have to excuse my lack of knowlage.

The reason I want to see the code is to combine several functions onto one button. However my VBA knowlage is not good enough to write it from scratch hence why I want to see an exisiting code and copy/modify it for my own needs.

I generally try and use the wizard or record a macro and look at the code behind them to create my own function, however this does not seem to work in this case.
 
You can duplicate the Embedded Macro in an external macro and then convert the external macro to code if you want.
 

Users who are viewing this thread

Back
Top Bottom