Invalid use of Property MS Access 2010

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sherianmartin
    New Member
    • Jan 2014
    • 14

    #1

    Invalid use of Property MS Access 2010

    Hi, I'm trying to assign a value to a field. eg
    Code:
    Me.pcmammogram-confirmed = "Yes"
    . However after I click or attempt to write somewhere else the system puts a space between the field. See below:

    Code:
    Me.pcmammogram-confirmed = "Yes" (this is how its written)
    Me.pcmammogram -confirmed = "Yes" (This is how it looks
    then I get this error: "Invalid Use of Property".
    Please help! Thanks.
    Last edited by zmbd; Jan 13 '14, 09:26 PM. Reason: [Z{Please use the [CODE/] button to format posted script and formated text - Please read the FAQ}]
  • kthprog
    New Member
    • Jan 2014
    • 2

    #2
    try
    Code:
    [Me.pcmammogram-confirmed] = "Yes"
    Sometimes this works for normally invalid field names.

    It's adding that space because it thinks the "-" is subtraction.

    I'm assuming this is VBA.
    Last edited by zmbd; Jan 13 '14, 09:25 PM. Reason: [Z{Please use the [CODE/] button to format posted script and formated text - Please read the FAQ}]

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      1)2)kthprog - invalid field names - hit it on the head.

      3)Please use the [CODE/] button to format posted script and formated text - Please read the FAQ

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        Z
        "kthprog - invalid field names - hit it on the head."

        He did, but unfortunately the example fix he posted wasn't quite correct. Try instead :
        Code:
        Me.[pcmammogram-confirmed] = "Yes"
        Now consider a couple of other issues.
        1. The item you refer to as a field is actually a control. Not too important but it helps when trying to communicate.
        2. Naming of items is much better done without using invalid characters where possible. The minus (-) is not recommended for use in names for the fairly obvious reason that it can easily be misunderstood.
          Also, if the name is PC Mammogram Confirmed, then this is much easier to read if you use capitals in the right places. Consider a name of PCMammogramConf irmed.
        3. If the field that the control is bound to is a Boolean field (One that takes Yes/No; True/False etc.) then assigning a string value to it, as your code showed, will not work as expected. In VBA a True value is written as True without any quotes.
        Last edited by zmbd; Jan 14 '14, 01:36 AM. Reason: [z{that's what I get for doing two things at once :) }]

        Comment

        Working...