[AccessD] Bang v. Dot

Borge Hansen pcs.accessd at gmail.com
Fri Aug 6 22:29:07 CDT 2021


Hello everyone,
I must admit the bang and dot has always been unclear to me...
Now using Access 365 and still rather than
Me!ControlName = "fred"
I almost constantly have used
me.ControlName = "fred"

For example this snippet has alway compiled since Access 2003
'+++++++
    If FIsLoaded("frmContactDetailsEdit") Then
        Forms!frmContactDetailsEdit.AList = strAlistValue
        Forms!frmContactDetailsEdit.lstCCategory.Requery
        Forms!frmContactDetailsEdit.Dirty = False
        Forms!frmContactDetailsEdit.UFN.SetFocus
    End If
'+++++++

Following best/right practice
(http://access.mvps.org/access/forms/frm0031.htm), the "proper"
notation should be
'++++++
    If FIsLoaded("frmContactDetailsEdit") Then
        Forms!frmContactDetailsEdit!AList = strAlistValue
        Forms!frmContactDetailsEdit!lstCCategory.Requery
        Forms!frmContactDetailsEdit.Dirty = False
        Forms!frmContactDetailsEdit!UFN.SetFocus
    End If
'++++++

... all form controls except for Dirty, right?

Interestingly when I write with a bang
        Forms!frmContactDetailsEdit!Dirty = False
the code compiles!!!

I tried this with a me!Dirty = false ... the code compiles
but when the code executes we get a "...can't find the field 'Dirty'
referred to in your expression"

However, I just re-tested the above code snippet and it appears that a
bang or dot preceding a form is equally OK, i.e. not only the code
compiles but it also does the job.
So I think I can stick with me.ControlName = "OK"

Or??

/borge

On Fri, Aug 6, 2021 at 11:06 PM Ryan W <wrwehler at gmail.com> wrote:
>
> I think a lot of the confusion comes from the fact that all your controls
> on a form also end up in collections, which can be bang notated.... in fact
> I think for a time that was considered "proper" to use a bang to access a
> control, and then naturally a dot to access a property of the control.
>
> eg
>
> Me!Username.SetFocus
>
> which is shorthand for
>
> Me("Username").SetFocus
>
> I use this page when I need a refresher:
>
> http://access.mvps.org/access/forms/frm0031.htm
>
> There were some articles written by the late David Fenton scattered around
> the web that suggested MS Access did not corrupt as easily during compiling
> or decompliling if you used bangs in place of dots where appropriate.   I'm
> unsure if that still holds true.
>
>
>
> On Fri, Aug 6, 2021 at 7:35 AM Arthur Fuller <fuller.artful at gmail.com>
> wrote:
>
> > Thanks  Stuart.
> >
> > On Fri., Aug. 6, 2021, 6:28 a.m. Stuart McLachlan, <stuart at lexacorp.com.pg
> > >
> > wrote:
> >
> > > Prior to 2007, Access was very forgiving and you could mix up dots and
> > > bangs with fewer
> > > problems.
> > >
> > > In 2007, MS tightened it up and applied the rules more consistently.
> > >
> > > In essence:
> > > A bang (!) indicates that what follows is a element of a collection.
> > > A dot (.) means a property, collection, or method name.
> > >
> > > For recordsets.
> > > rs.Addnew  '  method so it's a dot
> > > rs!Firstname = "Fred"   'it's an element of the recordset collection so a
> > > bang
> > > rs.Update ' again a method, so a dot.
> > >
> > >
> > > --
> > > Stuart
> > >
> > > On 6 Aug 2021 at 4:09, Arthur Fuller wrote:
> > >
> > > > When working with recordsets; I have seen both bang (rs!) and dot
> > > > (rs.) References. Wh6 is the difference? -- AccessD mailing list
> > > > AccessD at databaseadvisors.com
> > > > https://databaseadvisors.com/mailman/listinfo/accessd Website:
> > > > http://www.databaseadvisors.com
> > > >
> > >
> > >
> > > --
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > https://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> > >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com


More information about the AccessD mailing list