In VBA there is a cool feature called a With
statement that kind of lets you set the global scope for a block of code. This is useful to change multiple fields of an object and to call methods.
Here is an example:
With Forms!main
.Filter = "tel IS NOT NULL"
.FilterOn = True
.Requery 'This is a method!
If .Recordset.RecordCount> 3 Then
.BackColor = "Red"
End If
End With
In this example all the statements that begin with .
refer to fields and methods of Forms!main
.
I haven't come across a feature like this in any modern language (Javascript, c#, python) and I am wondering if there is a reason for this?