Thank you for clarifying the verbiage between Excel & Access (something I need to make a habit). Request clarification on your response. As you state you CAN use spaces or underscores, but was wondering if underscores alleviate the issue that spaces cause later in the advanced courses. Or is the underscore as problematic as the space?
Reply from Richard Rost:
The underscore DOES alleviate the problem. In a nutshell, the reason why I strongly urge AGAINST using spaces is because it becomes a nightmare later on if you get into advanced topics like writing your own SQL statements or VBA programming. For example, to refer to a field on an open form, you can just say:
MyValue = Forms!FormName!FieldName
However, if you have spaces in your form and field names, this has to become:
MyValue = Forms![Form Name]![Field Name]
You have to remember to put square brackets around EVERYTHING which does become a pain. Same thing with SQL statements:
SELECT * FROM CustomerTable WHERE CustomerID=5
becomes...
SELECT * FROM [Customer Table] WHERE [Customer ID]=5
So it's just MUCH easier to teach people in the beginning NOT to use spaces. But yes, to answer your question, underscores are just fine. This is perfectly valid:
MyValue = Forms!Customer_Form!First_Name
Hope this helps.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Access Beginner 3.