Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 16th, 2013, 08:08 AM
Registered User
 
Join Date: Apr 2009
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Default sql parametered stored procedure as form recordsource

I am trying to to set the results of a stored procedure as the recordsource of a form. This is because I want server side processing and thought that a multi parameter query is easier to write in t-sql than vba (the latter simply refuses to do a nz(parameter, select all records) type of thing).

So I have been trying this:
Code:
Private Sub btnFilter_Click()
Dim strConnection As String
    
    strConnection = "ODBC;DRIVER={SQL Server};SERVER=myserver;DATABASE=mydb;TRUSTED_CONNECTION=Yes;"
Me.RecordSource = ("Exec dbo_spFilterCases, " & Me.cmbCaseFilter & "," & Me.cmbFilterAdvisor & "," & Me.cmbFilterClientType & "," & Me.cmbFilterDate & "," & Me.txtDate1 & "," & Me.txtDate2 & " ")
but am getting an error, as access can't find the object. This makes some sense to me as I am sure I need to connect. However, I have no clue on how to do this. and then surely I would need to ferry the resulting recordset into access and then set it as a recordsource, or am I on the wrong track here?
Thank you for the help!

Last edited by BabaYaga; January 16th, 2013 at 08:15 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't See SQL tables and Stored Procedure azambee SQL Server 2000 1 October 24th, 2008 01:03 PM
SQL Server Stored Procedure doug SQL Server 2000 2 February 22nd, 2005 03:04 PM
Sql server Stored procedure ranakdinesh BOOK: Professional C#, 2nd and 3rd Editions 2 May 29th, 2004 12:08 AM
dymanic sql vs stored procedure prox_lae Oracle 0 February 19th, 2004 10:30 PM
SQL Stored Procedure... babloo81 SQL Server ASP 1 December 8th, 2003 03:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.