LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Laurent M
 
Posts: n/a
Default return recordset

Hello, I have a little VBA function which execute a SQL
query. The function should return the relevant recordset.

But i get an error when i try to get the recordset from a
query :

My function :

***************************************
Function ImportFromdb(Query As String)

Dim DBPath As String
Dim cnt As New ADODB.Connection
Dim Rst As New ADODB.Recordset

' Database path
DBPath = "C:\Documents and
Settings\Administrateur\Bureau\MyPFE\financesoftWi thData.mdb"

cnt.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=" & DBPath & ";"

Rst.Open Query, cnt, adOpenStatic

ImportFromdb = Rst

Rst.Close: cnt.Close
Set Rst = Nothing: Set cnt = Nothing
Set Rg = Nothing
End Function
***************************************

here is the part of the sub which calls the function

Dim Rst As New ADODB.Recordset
Set Rst = ImportFromdb("SELECT *FROM table")


So my question is : What should my function return precisely?

Thanks !
 
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
Formula to return cell contents based on multiple conditions Bill Excel Worksheet Functions 3 January 19th 05 09:59 AM
Can VLOOKUP return multiple answers based on several identical lo. jddtct Excel Worksheet Functions 3 January 11th 05 07:03 AM
Return the smallest value Donkey Excel Worksheet Functions 2 December 24th 04 10:10 PM
Carriage Return in Excel Rod Behr Excel Discussion (Misc queries) 4 December 14th 04 01:53 PM
Return the end of month date from a date Steve F. Excel Worksheet Functions 3 October 28th 04 06:17 PM


All times are GMT +1. The time now is 11:34 AM.

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

About Us

"It's about Microsoft Excel"