Solved

Export access 2010 form records to Excel

Posted on 2013-12-23
3
1,931 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 51

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

710 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