Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 1st, 2006, 05:12 PM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Output to Excel with selected field

Hi all,
I'm a pretty new with this so please help with patience.
I have a Query in Access that need to export to Excel. I usually use DoCmd.TransferSpreadsheet or DoCmd.OutputTo to do this and it works fine. Now, I want to output this Qry_file to Excel but in selected Group field. The user can select the group, from a combo box that list all the group number, then click the button and have the spreadsheet filtered by their selected group.
If you're not clear or have any question, please ask.
Thank you in advanced!
 
Old November 2nd, 2006, 09:43 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You want the user to use the same query you are already outputting? If so, on the On Click button to run your function, do this:

Dim sGroup, sLink, sDoc As String

sGroup = Me.GroupFieldName
sLink = "[GroupFieldName] = '" & sGroup & "'"
sDoc = "qryYourQueryName"

DoCmd.OpenQuery sDoc, , sLink

DoCmd.TransferSpreadsheet etc.

DoCmd.Close acQuery, sDoc

Something like that.

Does that help?


mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Update field on all selected records in a subform S300570 Access 1 January 14th, 2008 02:19 PM
Output existing value to new field Neal SQL Server 2000 5 March 12th, 2007 09:51 AM
ASP to Excel - excel output formatting issue mat41 Classic ASP Professional 0 August 13th, 2006 06:41 AM
To show selected related field of DDL1 in DDL 2 skirpane .NET Framework 1.x 1 June 1st, 2006 03:04 PM
Limiting of Calc. Field Output to 2 decimals Vince_Kingston SQL Language 1 June 9th, 2003 01:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.