Solved

Export access 2010 form records to Excel

Posted on 2013-12-23
3
1,961 Views
Last Modified: 2013-12-26
Does anyone have a way to export to excel only those records displayed on a filtered form in Access 2010 top Excel 2010?

Sandra
0
Comment
Question by:ssmith94015
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 200 total points
ID: 39736836
Hi,

pls try by creating a temporary table

Dim qrydef as QueryDef
DoCmd.DeleteObject acQuery, "qryTmp"
Set qrydef = CurrentDb.CreateQueryDef("qryTmp", Me.myForm.Form.RecordSource)
DoCmd.OutputTo acOutputQuery, "qryTmp", acFormatXLS, "C:\myXLFile.xls", True

Open in new window

Regards
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 300 total points
ID: 39736842
first create a query "qryExport"  with sql statement

select * from NameOfTable

use this code in the click event of a  button

Private Sub cmdExportToExcel_Click()
Dim sWhere As String, qd As DAO.QueryDef, nSql As String
If Me.Filter = "" Then
    sWhere = ""
    Else
    sWhere = Me.Filter
End If

Set qd = CurrentDb.QueryDefs("qryExport")
qd.sql = "select * from NameOfTable"
nSql = qd.sql & " Where " & sWhere
If Len(sWhere) > 0 Then
qd.sql = nSql
End If

DoCmd.TransferSpreadsheet acExport, 10, "qryExport", _
        "C:\ExportedToExcel.xlsx", True,


end sub
0
 

Author Closing Comment

by:ssmith94015
ID: 39740355
They both worked at setting up the query and I needed the transfer methodology
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question