HELP : Access Database
I am a new user.
I have a problem in access.
I have two tables with a different number of fields.
I have also two different forms connected to the tables.
On the form I have two text boxes.
I want to export both tables (through VBA control on_click procedure) to a new Excel workbook - each table to a different sheet, while performing a sql statement - to choose fields from the tables according to the text inserted in the text boxes.
Try TransferSpreadsheet Method
DoCmd.TransferSpreadsheet [transfertype][, spreadsheettype], tablename, filename[, hasfieldnames][, range]
tablename can be a query or sql statement if the transferType is acExport
use acSpreadsheetTypeExcel9 for spreadsheettype
Note: range is not valid for acExport
For more info look this up in the Access Help
Otherwise you will have to use automation
If you need help with automation let me know
I can help you with this
Build your Sql statements like this:
Dim Sql1 As String
Dim Sql2 As String
Sql1 = "select " & textbox1.Value & " from FirstTable"
Sql2 = "select " & textbox2.Value & " from OtherTable"
Note: these Sql statements will generate errors If the field names
are not spelled correctly and seperated by commas; but the last
one should NOT end with a comma.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL