[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

Access 2003 - ADODB Issue - Passing Parameter values to a recordset with a commond?

Asked by sabrina_spillane in Microsoft Access Database

Tags: access, adodb, 2003, parameters, forms

Hi All,


Here is my VBA Code , and i am trying to call a commond to open a query with certain parameter values and then with those specified parameters open a recordset. The errors I seem to be getting are as follows:
"Parameter object is improperly defined. Inconsistent or incomplete information was provided."

When I add in the Casting to a String lines to cast the parmeter to String I get the following:
"Item cannont be found in the collection corresponding to the requested name or ordinal"

Has any one got any ideas, please, thanks.

    Dim sSql 'As String
    Dim cn As New ADODB.Connection
    Dim rstReportDetails As New ADODB.RecordSet
    Dim cmd As ADODB.Command
    'create a paramter to hold all values
    Dim ProdId As ADODB.Parameter
    Dim CompId As ADODB.Parameter
    Dim AppNo As ADODB.Parameter
       
    'set values
    Set cn = CurrentProject.Connection
    Set cmd = New ADODB.Command
         
     'get the command object from the query
     With cmd
     .ActiveConnection = cn
     .CommandText = "Select * From qryRptDetails"     'THIS IS A QUERY WITH IN MY FRONT END DB
     .CommandType = adCmdText
     Set ProdId = .CreateParameter("par1")
     Set CompId = .CreateParameter("par2")
     Set AppNo = .CreateParameter("par3")

     'par1 = CStr(cmd.Parameters("par1"))
     'par2 = CStr(cmd.Parameters("par2"))
     'par3 = CStr(cmd.Parameters("par3"))

     .Parameters.Append ProdId
     .Parameters.Append CompId
     .Parameters.Append AppNo

    ' Set ProdId = cmd.Parameters("Forms!crpProduct!AppProductId")
    ' Set CompId = cmd.Parameters("Forms!crpProducts!comCompany")
     'Set AppNo = cmd.Parameters("Forms!crpProducts!txtAppendixNo")
     '.Parameters("par1") = Forms!crpProducts!AppProductId
     '.Parameters("par2") = Forms!crpProducts!comCompany
     '.Parameters("par3") = Forms!crpProducts!txtAppendixNo

     par1.Value = Forms!crpProducts!AppProductId
     par2.Value = Forms!crpProducts!comCompany
     par3.Value = Forms!crpProducts!txtAppendixNo
   'Execute
   End With

   'setting it to a record set
    rstReportDetails.Open cmd


Here is my Access Query that I want to call with in my VBA Code, it is looking for three parametes from the a form.

PARAMETERS Forms!crpProducts!AppProductId Long, Forms!crpProducts!comCompany Long, Forms!crpProducts!txtAppendixNo Long;
SELECT DISTINCT crpProducts.crpProduct_ID AS ProductID, crpProducts.crpProduct_CompanyID AS CompanyID, crpProducts.crpProduct_Description, crpProducts.crpProduct_ActivityDate, crpProducts.crpProduct_AppendixNo AS AppendixNo, crpProductTypes.crpProductType_Name, UnitCategory2Values.unitCat2Name, crpProductLicenseTypes.crpProductLicenseType_crpLicenseTypeID, crpLicenseTypes.crpLicenseType_Name, crpProducts.crpProduct_AgreementDate, crpProducts.crpProduct_IsLicensed, crpProducts.crpProduct_RevisedDate, tblPersonnel.Codes, People.PeopleEmail AS Email
FROM (((((crpProductTypes INNER JOIN crpProducts ON crpProductTypes.crpProductType_ID=crpProducts.crpProduct_crpProductTypeID) INNER JOIN crpProductLicenseTypes ON crpProducts.crpProduct_ID=crpProductLicenseTypes.crpProductLicenseType_crpProductID) INNER JOIN UnitCategory2Values ON crpProductTypes.crpProductType_Category2=UnitCategory2Values.unitCat2ID) INNER JOIN crpLicenseTypes ON crpProductLicenseTypes.crpProductLicenseType_crpLicenseTypeID=crpLicenseTypes.crpLicenseType_ID) INNER JOIN tblPersonnel ON crpProducts.crpProduct_CompanyID=tblPersonnel.CompanyID) INNER JOIN People ON tblPersonnel.PeopleId=People.PeopleId
WHERE (((crpProducts.crpProduct_ID)=(Forms!crpProducts!AppProductId)) And ((crpProducts.crpProduct_CompanyID)=(Forms!crpProducts!comCompany)) And ((crpProducts.crpProduct_AppendixNo)=(Forms!crpProducts!txtAppendixNo)) And ((crpProducts.crpProduct_IsLicensed)=True) And ((tblPersonnel.Codes) Like "%'L'%"))
ORDER BY crpProducts.crpProduct_CompanyID;
[+][-]12/12/06 05:50 AM, ID: 18122251Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Microsoft Access Database
Tags: access, adodb, 2003, parameters, forms
Sign Up Now!
Solution Provided By: LPurvis
Participating Experts: 2
Solution Grade: A
 
[+][-]12/12/06 04:55 AM, ID: 18121906Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/12/06 05:50 AM, ID: 18122256Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/12/06 05:57 AM, ID: 18122316Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/12/06 06:05 AM, ID: 18122383Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/12/06 06:26 AM, ID: 18122534Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/12/06 06:35 AM, ID: 18122617Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/12/06 06:42 AM, ID: 18122688Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/12/06 07:44 AM, ID: 18123250Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93