Solved

Export access 2010 form records to Excel

Posted on 2013-12-23
3
1,897 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
3 Comments
 
LVL 49

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
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…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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