none
How do I reference a query "CDate" column in a record set RRS feed

  • Question

  • I have an ADO Query with the following column..

    CDate(Table_1.[Usage Start Date]),

    How do I then reference this query column in a local record set?

    I have...

    rsL_Complete_Details_1.Fields("Usage Start Date")

    And its telling me that <Item cannot be found in the collection corresponding to the requested name or ordinal>

    Do I have to alias the column or can I reference the local record set column with CDate as well?

    Any help would be greatly appreciated.

    Thanks in advance for your review and am hopeful for a reply.

    PSULionRP

    Wednesday, September 19, 2012 5:43 PM

All replies

  • Hi PSULionRP

    I would try to add a watch from the Debug  to the recordset and see what are the columns names...

    HTH

    João

    Wednesday, September 19, 2012 7:05 PM
  • Hi PSULion

    "PSULionRP" schrieb im Newsbeitrag news:58178d5e-7d8e-4083-b3a9-b1c17ae0ca3@communitybridge.codeplex.com...

    I have an ADO Query with the following column..
    How do I then reference this query column in a local record set?
    I have...
    rsL_Complete_Details_1.Fields("Usage Start Date")

    This will not work, because you didn't provide an alias for the field and the fieldname can be randomly given such as "Expr1" or similar.

    You can change your ADO query as follows:

    CDate(Table_1.[Usage Start Date]) AS UsageStartDate,

    and then reference to the alias

    rsL_Complete_Details_1.Fields("UsageStartDate")

    or simplier

    rsL_Complete_Details_1("UsageStartDate")

    If you can't change the query you can use the ordinal number of the field (starting with 0) to reference to this column. Let's say the calculated field is the 3rd field in the record then you would reference it by:

    rsL_Complete_Details_1(2)

    HTH
    Henry


    Thursday, September 20, 2012 5:28 AM