Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Convert SQL query Sub to Function

I have a macro that queries an access database, and would like to turn
it into a user-defined function. The recordset that is returned should
always be one value only. I am stuck at this place in my code:

rst.Open SQLstr, conn
Range("C1").CopyFromRecordset rst

It works now, returning the value to Range("C1") on the worksheet. How
do I assign the query result to a function value? Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Convert SQL query Sub to Function

either of these espressions will give you the value

rst.getstring

rst.fields(0).value

"Steve" wrote:

I have a macro that queries an access database, and would like to turn
it into a user-defined function. The recordset that is returned should
always be one value only. I am stuck at this place in my code:

rst.Open SQLstr, conn
Range("C1").CopyFromRecordset rst

It works now, returning the value to Range("C1") on the worksheet. How
do I assign the query result to a function value? Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Convert SQL query Sub to Function

Beautiful, it works. Thanks.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert $ to actual numbers in an imported web query Alex Excel Discussion (Misc queries) 1 December 13th 09 03:14 PM
Convert hard coded query criteria to Parameter Query Melanie[_2_] Excel Discussion (Misc queries) 0 July 15th 08 09:59 PM
Convert integer to time query Bryony Excel Discussion (Misc queries) 10 May 9th 08 05:22 PM
Microsoft Query rejects "nz" function in Access Query Vaughan Excel Discussion (Misc queries) 0 May 4th 05 05:20 PM
Convert to a Parameter Query Al Eaton Excel Programming 3 July 9th 04 04:05 PM


All times are GMT +1. The time now is 11:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"