Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA and Excel

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm trying to transfer data from a table/query to an excel spreadsheet automatically (without forcing the database user to manually export anything) using VBA code that is activated when an event (such as clicking a button) occurs. In doing so, I've used the CreateObject function to reference and open an excel spreadsheet and application but the step I'm stuck on is finding the method that allows me to get information from the table objects in my database.

Any insight into this problem is appreciated, thanks
 
Curtice,
There are a few methods depending on what your final goal is. One easy way would be to use the DoCmd.TransferSpreadsheet to export your query (or table) to a file (be careful as it will overwrite the whole file)
then use the CreateObject - GetObject to open said workbook.

Or you could create a Data Query in Excel (done from excel) that you can set to refresh on open and once that is set up, just use your CreateObject - GetObject from Access to open it and it will update itself.

There is one other way a coworker of mine uses to place certain data in an existing worksheet but it takes 3 pages of code in Access.

Depending on the situation I prefer to use the TransferSpreadsheet as kind of a "Data Dump" and then link the sheet I'm using to that file or the updateable "Data Query".

Let me know what exactly your looking to do and I'll see if I can't help. Kyle

[anakin] + [curse] = [vader2]
[anakin] + [amidala] = [lightsaber]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top