Button Form

knice11

Registered User.
Local time
Today, 14:40
Joined
Jun 14, 2011
Messages
20
I need help creating a form with a button that will export to excel once it is clicked. What are the appropriate steps to take? I have already created a form with a button up there. I need to know what do I need to do to make sure it exports to excel once it is clicked.

1. Do I need to do a query to make sure this happens?
2. Can I setup a macro to make sure this will happen?

Of the two above, which is the least hardest to understand and work with? I haven't messed with vba code to much. If possible, I would like to avoid it. Any help would be greatly appreciated.
 
Actully you will need both. You need a query to define the data that is to be exported and then you will need to create a macro that will execute the export process using the query. In this macro you can define the path and filename that will be created with the exporting of the data.

You will then assign the macro in the OnClick event of the button.
 
Mr. B do I need to create the query and macro before I create the form? I am quite slow when it comes to access because this is the first time I have used it. The data must come from two different tables that I have already move to access. How is this done, correctly? For that macro, what exactly is the action I would need to set it as so it can refer back to the button?
 
Mr. B do I need to create the query and macro before I create the form? I am quite slow when it comes to access because this is the first time I have used it. The data must come from two different tables that I have already move to access. How is this done, correctly? For that macro, what exactly is the action I would need to set it as so it can refer back to the button?

It does not make any difference when you create the query or the macro relative to the form. You should first create the query. If the data is comming from two different tables, you must get the connection between the two tables correct so the query will be returning the correct set of records. When you have the query working, you can then create the macro. You did not say which version of Access you are using. At the moment I am using Access 2010 and in this version the action is "ExportWithFormatting". (In previous version I have not used a lot of macros. I use VBA code instead.)

Just follow the prompts for creating the macro. Save your macro giving is a descriptive name. Then in your form, select the button and display the Properties for the button. In the properties window, select the Event tab. locate the On Click event and click in the area to the right of the name of the event. Then click on the down arrow in that row and select the name you gave your macro when you saved it. This will cause the actions of your macor to be run when the button is clicked.
 

Users who are viewing this thread

Back
Top Bottom