Naming conventions for tables,queries and forms.

Derek

Registered User.
Local time
Today, 06:03
Joined
May 4, 2010
Messages
234
Hi All

I have a question about naming conventions. If we have suppose 10 queries linked to the form (subforms) or something like this. How should we name the objects to distinguish them from each other and the names that clearly define the purpose of the objects.

I had a look online and found guide to naming conventions but not sure how to name those 10 queries or multiple tables linked to the same form etc...

Any help will be much appreciated.

Thanks
 
Some people get religious about this, not me. My advice is to aim for consistency in which ever method you use.

Let's suppose you have a sales form with totals for yesterday, this week, last week, this month and this year. I would name those queries like so:

SalesTotals_Day_Prior
SalesTotals_Week_Current
SalesTotals_Week_Prior
SalesTotals_Month_Current
SalesTotals_Year_Current

That's just an example of how my naming system. In all honesty if those were my actual queries, I would try and get that data into one query---SalesTotals_ByPeriod. Where I would have a field inside it called 'Period' where I would define what period those totals were for (Year_Current, Day_Prior, etc.)

When you say you have 10 queries, it really makes me think you could reduce that like I would do with my SalesTotal example. Can you explain the difference between these 10 queries?
 
My queries always start with q.
Qs ,select query
Qa ,append.
Qu, update.
Qn, union
Qx, Crosstab.
Qd, delete

Tables, with tXXXX
Reports, with rMyReport
Etc...
 
I discourage the use of the underscore in object names for a couple of reasons.

In VBA the underscore already has a clear purpose of separating the object name from the event name.

Visually, an underscore is virtually a space and disjoins the parts of an object name in code.
 
plog's first two sentences pretty much summarize my viewpoint.

I used this convention:
tXXX = a table, linked to a BE file
tlXXX = a local table residing in the FE file acting as a temporary
qtXXX = a single-table query based on tXXX (and there is a good reason to have one of these having to do with what happens when a form tries to directly access a linked table)
qtlXXX = a single-table query based on a tlXXX table
but... qXXXjYYY was a JOIN based on tXXX and tYYY.

Most forms were just XXX, no "f" prefix. On the other hand, subforms were sbfXXX.

Reports were rptXXX IF the report was launched implicitly; otherwise, just the report name.

I didn't use macros so had no name for them.

Code was ALWAYS just the name of the module, no special prefix; ditto, the entry point names. PUBLIC CONSTANT values had prefixes related to their usage, as for example clrXXX constants for a specifically named color that wasn't vbRed or vbGreen, etc.

The point? I stuck to this convention - and it WAS a convention - because it WORKED FOR ME. Didn't care a whistle whether anyone else liked it.

Here's the payoff. For a little project with a couple of forms and five or six tables and maybe twenty queries, it almost doesn't matter what you do. But the more code you have, the more tables you have, and the more queries you have, the worse it will be to try to keep things straight. And THAT is where conventions pay off.

My project probably exceeded 50 tables and 200 queries, maybe about 70 forms (some of which were dedicated to single-entity table maintenance, the rest were the work-horse forms), maybe about 70 to 100 reports, and not less than 12 modules with anywhere from 500 to 1500 lines of code per module. When you get that big, you need to use conventions because it is too big to keep entirely in your head. The names start to blur together. THAT is when having a convention and sticking to it will pay off.

But as plog said,

My advice is to aim for consistency in which ever method you use.
 
Thanks Guys, I have a question about naming the queries. If a query involves about 3 to 4 tables then how should we name it.
My tables are starting with "tbl" prefix.
Queries are starting with "qry" prefix.

Any help will be much appreciated.

Many Thanks.
 
Generally I try an name a query meaningfully,but not too long, so if it was pulling in last months sales data for our Field Service department i would probably call it something like qryFSSalesLastMth
 

Users who are viewing this thread

Back
Top Bottom