Group:  Microsoft Access ยป microsoft.public.access.externaldata
Thread: Export query to Excel

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Export query to Excel
pokdbz 07.06.2006 14:30:05
I have this query:
SELECT PHQ.SSN, PHQ.PHQDate, PHQ.PHQTOT
FROM PHQ
WHERE (((PHQ.SSN)=[whichSSN]));


How can I export this to Excel programaticlly?
RE: Export query to Excel
Klatuu 07.06.2006 14:57:01
You will want to use the TransferSpreadsheet method. You will find detailed
instructions in VBA editor Help. The TransferSpreadsheet method, however,
will not accept an SQL string as the Table Name argument. You will need to
create a stored query with a parameter for the SSN. If you run this from a
form, you can reference the control on the form where the SSN is carried for
the parameter value.

"pokdbz" wrote:

[Quoted Text]
> I have this query:
> SELECT PHQ.SSN, PHQ.PHQDate, PHQ.PHQTOT
> FROM PHQ
> WHERE (((PHQ.SSN)=[whichSSN]));
>
>
> How can I export this to Excel programaticlly?
RE: Export query to Excel
pokdbz 07.06.2006 15:28:01
How do you create a stored query? And then use that to do the export?

"Klatuu" wrote:

[Quoted Text]
> You will want to use the TransferSpreadsheet method. You will find detailed
> instructions in VBA editor Help. The TransferSpreadsheet method, however,
> will not accept an SQL string as the Table Name argument. You will need to
> create a stored query with a parameter for the SSN. If you run this from a
> form, you can reference the control on the form where the SSN is carried for
> the parameter value.
>
> "pokdbz" wrote:
>
> > I have this query:
> > SELECT PHQ.SSN, PHQ.PHQDate, PHQ.PHQTOT
> > FROM PHQ
> > WHERE (((PHQ.SSN)=[whichSSN]));
> >
> >
> > How can I export this to Excel programaticlly?
RE: Export query to Excel
Klatuu 07.06.2006 15:38:02
From the database window, select Queries, Click New. It will ask you what
table or query you want to use for the query. Select the table. Then in the
query builder, select your fields. Use the Criteria row to put your Where
condition in, without the word Where. If you want to reference a control on
your form to pass the SSN, it would look something like:

Forms!frmMyFormName!WhichSSN

Read VBA Help on the TransferSpreadsheet method for details on it's syntax.

To call it, create a command button on your form and put the code for the
TransferSpreadsheet in the Click event.

"pokdbz" wrote:

[Quoted Text]
> How do you create a stored query? And then use that to do the export?
>
> "Klatuu" wrote:
>
> > You will want to use the TransferSpreadsheet method. You will find detailed
> > instructions in VBA editor Help. The TransferSpreadsheet method, however,
> > will not accept an SQL string as the Table Name argument. You will need to
> > create a stored query with a parameter for the SSN. If you run this from a
> > form, you can reference the control on the form where the SSN is carried for
> > the parameter value.
> >
> > "pokdbz" wrote:
> >
> > > I have this query:
> > > SELECT PHQ.SSN, PHQ.PHQDate, PHQ.PHQTOT
> > > FROM PHQ
> > > WHERE (((PHQ.SSN)=[whichSSN]));
> > >
> > >
> > > How can I export this to Excel programaticlly?
RE: Export query to Excel
pokdbz 07.06.2006 19:23:01
Worked perfect thanks

"Klatuu" wrote:

[Quoted Text]
> From the database window, select Queries, Click New. It will ask you what
> table or query you want to use for the query. Select the table. Then in the
> query builder, select your fields. Use the Criteria row to put your Where
> condition in, without the word Where. If you want to reference a control on
> your form to pass the SSN, it would look something like:
>
> Forms!frmMyFormName!WhichSSN
>
> Read VBA Help on the TransferSpreadsheet method for details on it's syntax.
>
> To call it, create a command button on your form and put the code for the
> TransferSpreadsheet in the Click event.
>
> "pokdbz" wrote:
>
> > How do you create a stored query? And then use that to do the export?
> >
> > "Klatuu" wrote:
> >
> > > You will want to use the TransferSpreadsheet method. You will find detailed
> > > instructions in VBA editor Help. The TransferSpreadsheet method, however,
> > > will not accept an SQL string as the Table Name argument. You will need to
> > > create a stored query with a parameter for the SSN. If you run this from a
> > > form, you can reference the control on the form where the SSN is carried for
> > > the parameter value.
> > >
> > > "pokdbz" wrote:
> > >
> > > > I have this query:
> > > > SELECT PHQ.SSN, PHQ.PHQDate, PHQ.PHQTOT
> > > > FROM PHQ
> > > > WHERE (((PHQ.SSN)=[whichSSN]));
> > > >
> > > >
> > > > How can I export this to Excel programaticlly?

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net