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 September 16th, 2009, 07:07 AM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default Object Doesn't support property or method

Hi All

I am trying to get records froms stored procedure in access and link it with combobox but it gives error




Private Sub Form_Load()

'Dim r As New ADODB.Recordset

'r.CursorLocation = adUseClient

'Set r = CurrentProject.Connection.Execute("sp_CustomerSecu rityFilterTest")
'Set Me!Combobox.Recordset = r

Dim r As New ADODB.Recordset
Dim c As New ADODB.Command

c.ActiveConnection = SQLcon
c.CommandText = "sp_CustomerSecurityFilter"
c.CommandType = adCmdStoredProc
Set r = c.Execute

Set Me!SelectCustomer.RowSource = r


End Sub

Here's my stored procedure

ALTER PROCEDURE [dbo].[sp_CustomerSecurityFilterTest]

AS
-- Insert statements for procedure here
SELECT CID, Customer, CID, A1, APC,rep FROM Customers


Any suggestion or advice

Thanks

Ayaz
 
Old October 16th, 2009, 09:08 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Generally to use a SELECT stored procedure, you would do this on the Access side:

Code:
'Open Connection
Set cn = New ADODB.Connection
cn.Open cString
 
'Create a new command object
Set cmdCommand = New ADODB.Command
cmdCommand.ActiveConnection = cn
 
'Specify the stored procedure to run
cmdCommand.CommandType = adCmdStoredProc
cmdCommand.CommandText = "usp_MySelectProcedure"
 
'Create the parameter if needed
Set prmRecID = cmdCommand.CreateParameter("@RecordID", adInteger, adParamInput)
prmRecID.Value = lRecordID 'Long
cmdCommand.Parameters.Append prmRecID
 
'Open recordset
Set rs = cmdCommand.Execute
Now you can use the recordset as you normally would.

On the server side, the stored procedure might look like:

Code:
USE [MyDatabaseName]
GO
ALTER procedure [dbo].[usp_MySelectProcedure]
  @RecordID   int
as 
 
SELECT CID, Customer, A1, APC,rep 
FROM Customers
WHERE CID = @RecordID
Did that help? Of course you wouldn't need the parameter.
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old November 16th, 2009, 07:35 AM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default

Hi donal

But I can't able to set Continous form Recordsource with recordobject

Regards

Ayaz





Similar Threads
Thread Thread Starter Forum Replies Last Post
VB6, COM, Object doesn't support this property... thenoseknows Classic ASP Professional 1 July 12th, 2007 05:54 PM
error - Object doesn't support this property jamara VBScript 1 September 10th, 2006 05:13 AM
OBJECT DOESNT SUPPORT THIS PROPERTY OR METHOD KGANESH2006 Classic ASP Basics 4 March 24th, 2006 11:15 AM
Object doesn't support this property or method ASP crmpicco Classic ASP Components 0 March 16th, 2006 01:26 PM





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