Consulting

Results 1 to 8 of 8

Thread: Solved: How to edit field values in ADO recordset ?

  1. #1

    Smile Solved: How to edit field values in ADO recordset ?

    Hi guys,

    Please anyone can help on the below issue.

    Issue: I need to update the fields value to "Blank" wherever field in recordset has NULL.

    Error: I am getting Automation Error for the below code.
    [vba]
    Do While Not .EOF
    For Each ObjField In .Fields
    If IsNull(ObjField.Value) Then
    rst.Fields(ObjField.Name).Value = "Blank"
    End If
    Next ObjField
    rst.MoveNext
    Loop
    [/vba]

    Kindly let me know where I am wrong! or more information is needed.

    Thanks
    Last edited by sagotianitin; 03-26-2013 at 12:47 PM.

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,727
    Location
    Which line actually causes the error? Are you sure the null field is a text field?

    Also, why use
    [vba]rst.Fields(ObjField.Name).Value = "Blank" [/vba]
    rather than
    [vba]ObjField.Value = "Blank" [/vba]
    Be as you wish to seem

  3. #3
    VBAX Tutor mohanvijay's Avatar
    Joined
    Aug 2010
    Location
    MADURAI
    Posts
    268
    Location
    you can do it in another way by passing update query by using ADODB.Connection object

  4. #4
    Hi Aflatoon,

    I tried with below code, still got the same automation error. And error is on the same line.



    [VBA]ObjField.Value = "Blank" [/VBA]


    Any other suggestion ??

  5. #5
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,727
    Location
    Is that field a text field?
    Be as you wish to seem

  6. #6
    Thanks everyone,this query has been resolved.

  7. #7
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,091
    Location
    How was it resolved?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  8. #8
    Hello,

    I didn't got the code for that. I changed my logic and used excel formulas. I changed the values to "Blank" wherever it was Spaces\NULL.

    Thanks

Posting Permissions

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