Results 1 to 2 of 2
  1. #1
    REBBROWN is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Posts
    14

    Export to Excel from Access with dropdown using VBA

    Hey guys,


    hoping someone can help me here.
    got a DB dumped in my lap and a TON of VB code, and told to ‘replicate’ which so far has not happened, both because of cryptic code and my knowledge level of VBA.

    1) need to export to Excel data from a table.

    Here is the SQL for it:
    ASM_SQL = "SELECT [ASM Translation Table All].CERTIFICATION, " & _
    "[ASM Translation Table All].[Certification Translation], " & _
    "[ASM Translation Table All].[Qual Type], " & _
    "[ASM Translation Table All].TMS, " & _
    "[ASM Translation Table All].[End Month ID] AS SQD " & _
    "FROM [ASM Translation Table All];"

    2) here is the export to Excel


    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "MyExportQuery", "" & LOCATIONFILE & " " & SQDName & ".xls", False
    DoCmd.DeleteObject acQuery, "MyExportQuery"

    3) a little more code to shed some ‘light’ on above transfer statement

    Set ASMSQL = DB.OpenRecordset(ASM_SQL)
    Set strExcelExport = DB.CreateQueryDef("MyExportQuery", ASM_SQL)
    If ASMSQL.EOF Then
    intExportListCount = 0
    Else
    ASMSQL.MoveLast
    End If
    intExportListCount = ASMSQL.RecordCount
    intCounter = 1
    ASMSQL.MoveFirst
    ExportFileName = "" & FILELOC & " " & SQDName & ".xls"
    OverrideFile = True

    Ok, this works fine, exports to Excel, no problems so I know this works but it’s what the powers that be want to follow once it arrives in Excel.
    They want Certification Translation, (2nd line in SQL statement above) to be in a drop down (or combo box) depending on how you refer to it.
    So 4 or 5 fields or columns populated in the exported Excel, but 2nd one to create programmatically a drop down and populated by the exported values from that field in the SQL.
    Is there a quick and easy way to do this, essentially a ‘cut and paste’ just to get it to work in case they decide they want another drop down from remaining fields?
    Any and ALL help will be greatly appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    You want to export records to a new spreadsheet and then set up a dropdown for one or more of the columns?

    This requires opening the Excel as a VBA object and manipulating the spreadsheets to create the lookup reference range and the dropdown properties. Will be very complicated code.

    Have you at least learned how to manually set lookup in Excel to have basic frame of reference?

    Why Excel and not viewing data in forms and reports?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Formatting Access Export to Excel - VBA
    By derekben in forum Import/Export Data
    Replies: 2
    Last Post: 07-01-2013, 02:19 PM
  2. Replies: 7
    Last Post: 04-25-2013, 03:47 PM
  3. Export Access data to Excel
    By kaysersoze in forum Access
    Replies: 0
    Last Post: 01-21-2012, 12:25 AM
  4. Export from Access to Excel
    By Eowyne in forum Import/Export Data
    Replies: 5
    Last Post: 04-23-2011, 07:08 PM
  5. Access export to Excel
    By Rick West in forum Import/Export Data
    Replies: 4
    Last Post: 01-09-2010, 03:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums