Using Hash (#) in a cell name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

A client requires that a column header in the spreadsheet I am creating be
called, specifically, "Cat #" for the purposes of their importer.

Using Access VBA I am doing a transfer spreadsheet from a query.

At the moment if I alias the column header in the query to "Cat #" it will
obviously appear as "Cat ." as it does not recognise the #.

There are 2 possible ways I could force the header name to be "Cat #".
Either from the query, if anyone knows how to get around this; or later using
vba worksheet.range.name.

Assistance/suggestions would be greatly appreciated.
 
The # should NEVER be used in a name in Access. Names should be limited to
using Letters, Numbers, and the Underscore _. Using special characters other
than the underscore can lead to numerous problems. It is also necessary to
be sure you don't use any Access reserved words - Date, Year, Type,
Description, Month, etc.

In addition, to ensure you avoid such problems, you should adopt a naming
convention that precludes the inadvertant creation of such names. Here is a
link you can use to get an idea on some common naming conventions:

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnaraccess/html/msdn_20naming.asp

Sometimes, it is best for you and your client if you offer them you expert
advice on the why of the issue. If you let the client insist on making bad
decisions, you are doing them a disservice.

In reality, the user shouldn't see field names, anyway.
 
Klatuu said:
In addition, to ensure you avoid such problems, you should adopt a naming
convention that precludes the inadvertant creation of such names. Here is a
link you can use to get an idea on some common naming conventions:

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnaraccess/html/msdn_20naming.asp

As an alternative here are mine.

Tony's Table and Field Naming Conventions
http://www.granite.ab.ca/access/tablefieldnaming.htm

Tony's Object Naming Conventions
http://www.granite.ab.ca/access/tonysobjectnamingconventions.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Interesting stuff, Tony. I can agree with a lot of what you say. I have
been toying with the idea of prefixing by logical group.
I disagree with using spaces in name, but you are allowed to make mistakes
if you prefer.
I also think object naming prefixes is a bit of overkill, but it does
prevent the inadvertant use of a reserved work.
I do like varialbe naming conventions because it is easy to tell what the
purpose of a variable is at a glance.

I would say the only reason I stink with the published conventions is to be
merciful to the poor slob who has to follow behind me.
 
Klatuu said:
Interesting stuff, Tony. I can agree with a lot of what you say. I have
been toying with the idea of prefixing by logical group.
I disagree with using spaces in name, but you are allowed to make mistakes
if you prefer.

No spaces in field or table names agreed. But in other types of
objects this isn't a problem.
I would say the only reason I stink with the published conventions is to be
merciful to the poor slob who has to follow behind me.

Whereas I don't have to worry too much about that.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Back
Top