[AccessD] With / End With or not?

John Colby jwcolby at gmail.com
Mon Sep 13 14:29:48 CDT 2021


I use with / end with all the time, for any object I am going to reference
several properties of.

With rst
 .MoveLast
 .movefirst
!Fields("MyFieldName")=1234
'
'
.Update
end with

With CboSomeVal
.visible = true
.BackColor=vbCyan
end with

And so forth.

TBH I only do it to make coding faster and cleaner.  Referencing the object
name over and over is just icky.  I have never tested whether it made
execution faster.  I would think that it would, though with the speed of
today's processors it probably wouldn't matter except in a long loop

On Mon, Sep 13, 2021 at 1:59 PM Arthur Fuller <fuller.artful at gmail.com>
wrote:

> Somewhere I read or heard or just intuited that given a block of code that
> frequently references Me, it's faster and better towrap te the block in a
> With Me / End With than to explicitly refer to Me. Is this true? Or is it
> just to make the code ceaner? Has anyone bothered to benchmark the
> difference? I' could easily build a test case, but if you've already done
> it, then I would be interested in your results.
>
> --
> Arthur
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


-- 
John W. Colby
Colby Consulting


More information about the AccessD mailing list