[AccessD] Bang and Dot operator in Runtimes.

A.D.TEJPAL adtp at hotmail.com
Tue Aug 22 01:47:16 CDT 2006


John,

    In Access 2000 as well as 2003, tests conducted on form named F_BangDot, having unbound text boxes named TxtDate_A to L, all the eleven alternative statements in click event of command button CmdTest, as given below, are found to work effectively.

    The problem reported by you should not have any reason to occur. You might like to try it out on a newly created form. If still any problem, I could send you a copy of this form if desired, demonstrating all the alternatives.

    For use within code module of a form containing the text box in question, use of Me identifier, as in statement (A) below, is considered most efficient.

Best wishes,
A.D.Tejpal
---------------

======================================
Private Sub CmdTest_Click()
    Me.TxtDate_A = #1/1/2001#                                ' (A)
    
    
    Me("TxtDate_B") = #1/2/2001#                            ' (B)
    Me!TxtDate_C = #1/3/2001#                                ' (C)
    
    Me.Controls("TxtDate_D") = #1/4/2001#               ' (D)
    Me.Controls!TxtDate_E = #1/5/2001#                   ' (E)
    
    Forms("F_BangDot")("TxtDate_F") _
                                                = #1/6/2001#            ' (F)
    Forms!F_BangDot!TxtDate_G = #1/7/2001#         ' (G)
    
    Forms("F_BangDot").Controls("TxtDate_H") _
                                                = #1/8/2001#            ' (H)
    Forms!F_BangDot.Controls!TxtDate_J _
                                                = #1/9/2001#            ' (J)
                                                
    Forms("F_BangDot").TxtDate_K = #1/10/2001#    ' (K)
    Forms!F_BangDot.TxtDate_L = #1/11/2001#        ' (L)
    
    ' Note:
    ' (a) Statement (A) is considered the most efficient
    '       when used within code module of form
    '       containing the text box. - although all the oher
    '       statements, i.e. (B) to (L) are also found to
    '       work effectively.
    ' (b) Statement (B) is the preferred short style of
    '       complete syntax represented by statement (D).
    '       This syntax can be adopted universally by
    '       substituting Forms("FormName") instead of Me
    '       as illustrated in (F) and (H).
    ' (c) Statements (C), (E), (G) and (J) are equivalent
    '       to (B), (D), (F) and (H) respectively, but with
    '       bang operator.
    ' (d) Statements (K) & (L) are hybrid versions.
    ' (e) Basically, bang operator is meant as a replacement
    '       for ("--") style, when referring to a member in
    '       a collection.
    
    ' Important:
    '       In queries, bang operator is the only one that is
    '       accepted.
End Sub
======================================

  ----- Original Message ----- 
  From: John Skolits 
  To: 'Access Developers discussion and problem solving' 
  Sent: Tuesday, August 22, 2006 07:39
  Subject: Re: [AccessD] Bang and Dot operator in Runtimes.


  Actually, it is a bound form, but this turns out to be an unbound text box on the form. So, there is no field named "txtDate", just the text box name. Therefore, why would the "!" work and not the "."

  I could certainly re-design the form, but the reason for posting the
  question in the first place is to find out why is this happening anyway.
  And I've seen it many times before. Must have something to do with it being an unbound control. 

  John

  -----Original Message-----
  From: accessd-bounces at databaseadvisors.com
  [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Erwin Craps - IT
  Helps
  Sent: Monday, August 21, 2006 5:44 PM
  To: Access Developers discussion and problem solving
  Subject: Re: [AccessD] Bang and Dot operator in Runtimes.

  When using me.txtdate your are refering to the control on a form.
  When using me!txtdate you are refering to the field from the forms
  recordset (rowsource). 

  But for what concerns your error.
  When using me.txtDate = #1/1/2001# the code can fails depending of whats in the controlsource. If you replace the . By a ! Than you maybe have no error but you are refering tho the field instead of the control (in case a field exists with that name).

  -----Oorspronkelijk bericht-----
  Van: accessd-bounces at databaseadvisors.com
  [mailto:accessd-bounces at databaseadvisors.com] Namens John Skolits
  Verzonden: maandag 21 augustus 2006 21:46
  Aan: 'Access Developers discussion and problem solving'
  Onderwerp: [AccessD] Bang and Dot operator in Runtimes.

  I've been able to fix this by making some changes in code but want to
  know if anyone has additional info on why this occurs.

  Sometimes, referring to a text box with the "." operator sometimes fails
  in runtime apps.

  me.txtDate = #1/1/2001#  'Causes an error Vs.
  Me!txtDate = #1/1/2001#

  The error message I get is that the dot operator is invalid.

  I simply change it and it's fine. Yet, on other forms, it's working.

  I re-import and uncompile/compile many times on these apps and it still
  doesn't seem to always catch the potential problem.

  Any thoughts?

  John


More information about the AccessD mailing list