Home Forums Microsoft Access Microsoft Access Access 2003 adp: Run-time error ''91'': Object variable or with block variable not set RE: Access 2003 adp: Run-time error ''''91'''': Object variable or with block variable not set

  • Hi Cory, Thanks for your kind response and valuable code for doing the "Rotate a Table" in Access 2003.

    I tried to do it as you instructed. First I did write the VBA code in the Module and then tried to set up the Stored Procedure Year_In_@year_In_out_return that I encountered difficulties:

    (Problem#1) On the code statement .Parameter ("@year") = 1995, I got the following error:  Run-time error '3265': Item cannot be found in the collection corresponding to the requested name or ordinal.

    I tried to write a Stored Procedure Year_In_@year_In_out_reurn in the Query, I got  (Problem #2): Microsoft Office Access-ADO error: Incorrect syntax near the keyword 'FROM'. or ADO error: Incorrect syntax near the keyword "SELECT". Line 3: Incorrect syntax near 'SUM', wheh I tried to complete the following: ALTER PROCEDURE dbo.Year_In_@year_In_out_return

    SELECT year=q.year

    SUM(CASE quarter WHEN 1 THEN amount ELSE 0 END) as Q1

    SUM(CASE quarter WHEN 2 THEN amount ELSE 0 END) as Q2

    SUM(CASE quarter WHEN 3 THEN amount ELSE 0 END) as Q3

    SUM(CASE quarter WHEN 4 THEN amount ELSE 0 END) as Q4

    FROM QTRSALES  q

    WHERE year = @year

    GROUP BY year

    //////////////////////////////////////////////

    I feel that I can not set up the above-mentioned Stored Procedure in the Query of Access 2003 because Access 2003 is so limited and it is not designed as the Query Analyst of SQL Server 2000.  Am I right in this aspect?  If I am wrong in this aspect, please give me more instructions for setting up the desired Stored Procedure in the Query of Access 2003.

    I have one more question to ask you: What is the 'year=q.year' in the code statement "SELECT year=q.year"?

    Please help and respond.

    Thanks,

    Scott  Chang