VBA Export Sub Query To Excel

shamas21

Registered User.
Local time
Today, 22:46
Joined
May 27, 2008
Messages
162
Hi All

I have a query called 'Query1' ebmedded in to my search form called 'Form1'.

I want to create a button that allows the user to export all the information displayed in the 'Query1' that is embedded within the form.

How can i do this?

Thanks
 
Hi All

I have a query called 'Query1' ebmedded in to my search form called 'Form1'.

I want to create a button that allows the user to export all the information displayed in the 'Query1' that is embedded within the form.

How can i do this?

Thanks

Hi, if you're saying that you want Query1 to be filtered by what is selected on Form1. I tried this

Code:
mySQL = "SELECT [Name], [DOB], [Sub-Category] "
mySQL = mySQL & "INTO Temp "
mySQL = mySQL & "FROM Query1 "
mySQL = mySQL & "WHERE [Sub-Category] = '" & [COLOR=red]Me.Combo0.Value[/COLOR] & "';"
Debug.Print mySQL
DoCmd.RunSQL mySQL

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Temp", "Temp.xls", True

The control in Red is seen as the filter element

Does this help?
 
many thanks, works great :)
 
many thanks, works great :)

:eek: OMG really (doubting own ability) ... does lap of honor with shirt over head...this raises my confidence ..what did i do again:confused:...(suddenly worrying what advice i actually gave..)..oh yeah..

..anytime m8
 

Users who are viewing this thread

Back
Top Bottom