HELP : Access Database


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: HELP : Access Database

  1. #1
    Join Date
    Feb 2005
    Posts
    1

    HELP : Access Database

    Hi,

    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.

    PLEASE HELP
    Thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263

    Try TransferSpreadsheet Method

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center