Results 1 to 4 of 4
  1. #1
    seeker63 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    3

    code referenceing stored procedure put in recordset

    Why would following code give error "invalid property use" at rst



    Dim cmd As ADODB.Command
    Dim rst As ADODB.Recordset
    Set cmd = New ADODB.Command
    cmd.ActiveConnection = CurrentProject.Connection
    cmd.CommandType = adCmdStoredProc
    rst = cmd.Execute("prcRPTPlantPastDuePaymentsReportCO2")

  2. #2
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    It may be just the word "Set" missing before rst =, but your usage doesn't seem to match the parameters of the Execute method for a Command object: http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

    I'd switch the code to something like:
    Code:
       Set cmd = New ADODB.Command
       cmd.ActiveConnection = CurrentProject.Connection
       cmd.CommandText = "prcRPTPlantPastDuePaymentsReportCO2"
       cmd.CommandType = adCmdStoredProc
       Set rst = cmd.Execute()
    You can also try this syntax replacing the last line:
    Code:
       Set rst = New ADODB.Recordset
       rst.Open cmd
    Reference - http://msdn.microsoft.com/en-us/library/office/aa160695

  3. #3
    seeker63 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    3
    Seems to have done the trick. Thanks.

  4. #4
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    You're welcome. Please mark thread as solved. Top of page, under thread tools.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. write stored procedure with 'if else'
    By shital in forum Access
    Replies: 9
    Last Post: 04-11-2018, 11:47 AM
  2. Stored Procedure in MS Access 2007
    By sels1987 in forum Access
    Replies: 1
    Last Post: 05-13-2012, 12:23 PM
  3. Replies: 5
    Last Post: 09-26-2011, 03:58 AM
  4. Executing Oracle Stored Procedure
    By gsurfdude in forum Programming
    Replies: 0
    Last Post: 03-01-2011, 09:23 AM
  5. Replies: 0
    Last Post: 05-12-2010, 09:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums