Results 1 to 8 of 8

Thread: [RESOLVED] Update ADO recordset error 3265

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Resolved [RESOLVED] Update ADO recordset error 3265

    i am trying to do a basic update of a few fields

    this works
    Code:
        tmp(0) = Text1(0)
        tmp.Update
    so i have no real problem, just would like to know why i am getting the error

    rather than updating each of the fields, would prefer to use
    Code:
        tmp.Update tmp.(0), Text1(0)
    where the fields and values should be able to be arrays (as with addnew, which works fine)
    but testing either individual fields or arrays give the error 3265
    "Item cannot be found in the collection corresponding to the requested name or ordinal"

    i have also tried tmp.fields(0) and tmp("fieldname")

    i am able to access all fields in select queries
    any suggestions?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Update ADO recordset error 3265

    I think this might be the trouble: The two optional arguments must be Variant.

    Code:
    Private Sub cmdUpdate_Click()
        'Show use of RS.Update to update a single field at a time by ordinal.
        Dim F As Long
    
        With RS
            For F = 0 To Label1.UBound
                'Update by ordinal F:
                .Update CVar(F), CVar(Text1(F).Text)
                'This (by name) works as well:
                '.Update CVar(.Fields(F).Name), CVar(Text1(F).Text)
            Next
        End With
    Be wary of relying on default properties of objects too. There are lots of places where that can get you into trouble.
    Attached Files Attached Files

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Update ADO recordset error 3265

    explicitly converting the fields and values to variant made no difference

    your demo works perfectly, even without explicitly converting fields to variant, the only difference i see is the cursor location (useserver) in mine, so i tried changing that, but no difference

    i will follow up more tomorrow
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Update ADO recordset error 3265

    Yes, depending on what you pass you may sometimes get away without explicitly converting to Variant.

    But I wonder if you are tripping over the default property problem?

    You have this above:

    Code:
    tmp.Update tmp.(0), Text1(0)
    But that should not even compile. maybe you really have this?

    Code:
    tmp.Update tmp(0), Text1(0)
    That is passing the .Value of Fields(0), not the .Name so maybe:

    Code:
    tmp.Update tmp.Fields.Item(0).Name, Text1(0).Text
    I think this is also a reasonable thing to use, and should work as well:

    Code:
    tmp.Update tmp(0).Name, Text1(0).Text

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Update ADO recordset error 3265

    tmp.Update tmp.(0), Text1(0)
    that is a typo in the post only, at that point i had tmp.fields(0), and i failed to remove the .with fields

    i also tried
    Code:
        af = Array(tmp(0))
        av = Array(tmp(1))
        tmp.Update af, av
    which of course is not the desired result, but the same error occurred anyway
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Update ADO recordset error 3265

    You are calling tmp.Update passing the value of Field(0) and the value of Field(1) there. What do you think that's going to do?

    The 1st argument is a field name or ordinal (or array of them). Passing random crap will produce exactly the exception you are seeing.

  7. #7
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,229

    Re: Update ADO recordset error 3265

    Quote Originally Posted by MSDN
    Update Method

    Saves any changes you make to the current record of a Recordset object.

    Syntax

    recordset.Update Fields, Values

    Parameters

    Fields Optional. A Variant representing a single name or a Variant array representing names or ordinal positions of the field or fields you wish to modify.

    Values Optional. A Variant representing a single value or a Variant array representing values for the field or fields in the new record.
    ....

    maybe try

    Code:
        af = Array(0,1)
        av = Array(Text1(0).Text,Text1(1).Text)
        tmp.Update af, av
    Last edited by DEXWERX; Sep 27th, 2016 at 09:22 AM.

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Update ADO recordset error 3265

    thank you for your inputs i have now figured what i was doing wrong, so this specific error is resolved, i now have another error, so i will stay with editing the fields, then update without arguments
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width