PDA

View Full Version : Solved: How to edit field values in ADO recordset ?



sagotianitin
03-26-2013, 11:47 AM
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.


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


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

Thanks

Aflatoon
03-27-2013, 02:20 AM
Which line actually causes the error? Are you sure the null field is a text field?

Also, why use
rst.Fields(ObjField.Name).Value = "Blank"
rather than
ObjField.Value = "Blank"

mohanvijay
03-27-2013, 05:45 AM
you can do it in another way by passing update query by using ADODB.Connection object

sagotianitin
03-28-2013, 02:04 AM
Hi Aflatoon,

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

http://www.vbaexpress.com/forum/C:\Users\nitin.d.jain\Desktop\Error.jpg


ObjField.Value = "Blank"


Any other suggestion ??

Aflatoon
03-28-2013, 03:29 AM
Is that field a text field?

sagotianitin
05-24-2013, 01:22 AM
Thanks everyone,this query has been resolved. :)

Aussiebear
05-26-2013, 03:21 PM
How was it resolved?

sagotianitin
05-29-2013, 05:04 AM
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 :)