By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,335 Members | 2,218 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,335 IT Pros & Developers. It's quick & easy.

Invalid use of Property MS Access 2010

P: 14
Hi, I'm trying to assign a value to a field. eg
Expand|Select|Wrap|Line Numbers
  1. Me.pcmammogram-confirmed = "Yes"
. However after I click or attempt to write somewhere else the system puts a space between the field. See below:

Expand|Select|Wrap|Line Numbers
  1. Me.pcmammogram-confirmed = "Yes" (this is how its written)
  2. Me.pcmammogram -confirmed = "Yes" (This is how it looks 
then I get this error: "Invalid Use of Property".
Please help! Thanks.
Jan 13 '14 #1
Share this Question
Share on Google+
3 Replies

P: 2
Expand|Select|Wrap|Line Numbers
  1. [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.
Jan 13 '14 #2

Expert Mod 5K+
P: 5,397
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
Jan 13 '14 #3

Expert Mod 15k+
P: 31,494
"kthprog - invalid field names - hit it on the head."

He did, but unfortunately the example fix he posted wasn't quite correct. Try instead :
Expand|Select|Wrap|Line Numbers
  1. 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 PCMammogramConfirmed.
  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.
Jan 14 '14 #4

Post your reply

Sign in to post your reply or Sign up for a free account.