Home > Archive > MS Access database support > April 2006 > Another Excel Automation Newbie Question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Another Excel Automation Newbie Question
Keith Wilby

2006-04-07, 7:42 am

If I have a query with one field I can write the results to an existing
Excel spreadsheet using

objSht.Range("BK22").CopyFromRecordset rs

What happens if my query has two fields but I only want to write one of them
to the spreadsheet? I thought I could reference the field using either

objSht.Range("BK22").CopyFromRecordset rs("Result")

or

objSht.Range("BK22").CopyFromRecordset rs![Result]

but both silently fail ("Result" is an alias in the query). Any clues?

Many thanks.
Keith.


Randy Harris

2006-04-07, 9:37 am

Keith Wilby wrote:
> If I have a query with one field I can write the results to an existing
> Excel spreadsheet using
>
> objSht.Range("BK22").CopyFromRecordset rs
>
> What happens if my query has two fields but I only want to write one of them
> to the spreadsheet? I thought I could reference the field using either
>
> objSht.Range("BK22").CopyFromRecordset rs("Result")
>
> or
>
> objSht.Range("BK22").CopyFromRecordset rs![Result]
>
> but both silently fail ("Result" is an alias in the query). Any clues?
>
> Many thanks.
> Keith.
>
>


Keith, I think the syntax you want is:

objSht.Range("BK22"). CopyFromRecordset(rs
, , 1)

HTH
--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com