Form Component Naming Prefix (1 Viewer)

MattBaldry

Self Taught, Learn from the Forums
Local time
Today, 19:47
Joined
Feb 5, 2019
Messages
292
Hi all,

Just wondered what sort of naming prefixes people use on form components?

Currently I have something like the below.

cmd = Command Button IE cmdAdd, cmdEdit
txt = Text Field IE txtCustomerID, txtCustomerName
lbl = Label IE lblCustomerID, lblCustomerName
cbo = Combo Box IE cboCustomerType, cboCustomerPaymentTerms
lst = List Box IE lstCustomerContacts
img = Image IE imgCustomerLogo

Just wondered what prefix setups others use. Or do people not really bother with this?

~Matt
 

Minty

AWF VIP
Local time
Today, 19:47
Joined
Jul 26, 2013
Messages
10,355
That is pretty similar to what I use, and I suspect others do.

Someone on here posted up a demo of renaming all form controls based on a similar set of prefixes.
Obviously, you would really want to do this before building any code on the form.
 

MattBaldry

Self Taught, Learn from the Forums
Local time
Today, 19:47
Joined
Feb 5, 2019
Messages
292
Absolutely. Attached is a paper I found years ago that I try to adhere to as much as I can.
Thank you for that document, it is very useful and freaky that having never read anything like this, my OCD has lead me to almost use this same layout.

I think I will stick with what I have and just steal a few of the other things like field names in table prefixed with the data type.

~Matt
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 15:47
Joined
Apr 27, 2015
Messages
6,286
You're welcome.

I think I will stick with what I have and just steal a few of the other things like field names in table prefixed with the data type.
I tried that but found it tedious and my lack of OCD and copious amount of laziness won the day!
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 06:47
Joined
Jan 20, 2009
Messages
12,849
my OCD has lead me to almost use this same layout
You hit the nail on the head there. It is largely a fetish, particularly among Access developers. Some get really obsessed with it. It is also popular in Visual Basic but it is rare in other languages.

It was popularised in Access as slightly different flavours by Greg Reddick and Stan Leszynski with the Leszynski Naming Convention being the better known term. The concept was based on a system used by Charles Simonyi for typeless variables in early programming languages which became known as Hungarian Notation.

Some developers like the way the same types of objects are listed together in Intellisense but in my mind this artificially associates objects that nothing to do with each other and makes for more tying before you get to the object you are seeking.
things like field names in table prefixed with the data type.
Why?
 

Minty

AWF VIP
Local time
Today, 19:47
Joined
Jul 26, 2013
Messages
10,355
The main reason I started doing it was to avoid any possibility of ambiguity between the control or underlying field on a form.
Whilst, in theory, it doesn't often cause a problem, I have seen lots of posts over the years where it has caused confusion.

I don't prefix table fields with anything, that seems a total waste of time.
The only exception would be an occasional addition of Txt or Date as a suffix if there are similarly named fields.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:47
Joined
Feb 19, 2002
Messages
42,973
Twenty-Five years ago when I was developing with COBOL, I always prefixed all my table columns with a few characters that identified the source table. But, that was before intellisense and Access. The problem with prefixes for column names is they require extra typing before intellisense kicks in and when you open a table or query in DS view all you see are the prefixes which is seriously annoying. I do prefix variable names but mostly because it distinguishes them from table columns and bound controls. As the first part of the prefix, I use a g to indicate that the variable is global and const for constants.
 

Cronk

Registered User.
Local time
Tomorrow, 06:47
Joined
Jul 4, 2013
Messages
2,770
I don't bother renaming labels unless I refer to them in code, in which case it has the same name as the corresponding control except with the prefix lbl.
 

JonXL

Active member
Local time
Today, 14:47
Joined
Jul 9, 2021
Messages
153
Consistency is the real key. I use cmb for comboxes, which I suppose could be a dyslexic's nightmare with cmd, but it works well for me.
 

GinaWhipp

AWF VIP
Local time
Today, 15:47
Joined
Jun 21, 2011
Messages
5,901
I use...
Since I use use Model Databases with existing Forms not much to do should I add a new control to any one of the Forms. I even names Forms of the like the dame, i.e. frmFilter*** will always be the Form that opens to filter reports by. Naming Forms like that helps me find them easier as some of the databases end with a lot of Forms.

I think the key is finding what works for you.
 

Users who are viewing this thread

Top Bottom