Gillian has attended:
Access VBA course
Excel Advanced course
Short cut to updating multiple field properties
Hi,
I am updating fields in a table recorset. Is there a quicker way to update multiple fields in a recordset in the same way e.g. Trim them all rather than code it individually for each field?
Conversely is there a quicker way to do lots of things to one (or many) field rather than code it individually e.g. for a field I want to trim it, do a few find and replaces, set to lower case etc?
Thanks.
RE: short cut to updating multiple field properties
Hi Gillian
If you need to tidy up every field in a similar way you could shorten your code and write a function to use on each field.
For Example
Function TidyUp(stOrigValue)
TidyUp = Trim(stOrigValue)
TidyUp = LCase(TidyUp)
End Function
and then when processing your fields
With rsMyTable
.fields("UserName")=TidyUp(.fields("UserName")
...
.Update
End With
Hope that helps
Laura