General question about naming conventions for forms

  • Thread starter Mister John Doe
  • Start date
M

Mister John Doe

As I am building this application, I am trying to put it together in a
way that will reduce as much as possible any headaches that come when
trying to modify it in the future.

So one of the things I am thinking about is the way forms are opened
and handled in Access. When I transfer control to other forms, I need
to refer to that form, of course, and that's done by providing the
form's name in a string. There are some forms that I am creating as
general forms and they will be called from many different forms.

So, if I decide down the road to change the name of a form (for some
reason) then to get things to work correctly I will need to go to
every place that I have hard-coded the old name of the form and I will
have to hard-code the new name.

I was thinking that instead of doing this I would declare each form
name in a MAIN or GENERAL module. I would declare each form name as a
global string constant. Then I use the global string constant
throughout the application. If I ever need to change the name of a
form then I need to change it in only one place - the declaration for
the global string constant.

But I was wondering if this will buy me anything. Will this save me
the time and headache I am hoping it will save? Or is this not a good
practice?

As you can probably tell, I am new to programming in Access (been
doing it about three weeks now) and I am not sure if there are some
"lessons learned" that are out there. If this is a bad idea, please
let me know. Or if this is a good idea, let me know that also.
 
R

Rick Brandt

Mister John Doe said:
As I am building this application, I am trying to put it together in a
way that will reduce as much as possible any headaches that come when
trying to modify it in the future.

So one of the things I am thinking about is the way forms are opened
and handled in Access. When I transfer control to other forms, I need
to refer to that form, of course, and that's done by providing the
form's name in a string. There are some forms that I am creating as
general forms and they will be called from many different forms.

So, if I decide down the road to change the name of a form (for some
reason) then to get things to work correctly I will need to go to
every place that I have hard-coded the old name of the form and I will
have to hard-code the new name.

I was thinking that instead of doing this I would declare each form
name in a MAIN or GENERAL module. I would declare each form name as a
global string constant. Then I use the global string constant
throughout the application. If I ever need to change the name of a
form then I need to change it in only one place - the declaration for
the global string constant.

But I was wondering if this will buy me anything. Will this save me
the time and headache I am hoping it will save? Or is this not a good
practice?

As you can probably tell, I am new to programming in Access (been
doing it about three weeks now) and I am not sure if there are some
"lessons learned" that are out there. If this is a bad idea, please
let me know. Or if this is a good idea, let me know that also.

I would say it is a good idea if it coincides with a bad practice which is to
make a habit of changing the names of your forms. This should be so rare an
event that your good idea becomes unnecessary.

In other words, if you add the additional up front work and run the risk of
making your code a bit harder to understand by doing this only to find out a
year or two from now that you only ever changed the name of a form once or
twice, then it was a waste of your time. However; if you find afterwards that
you are changing the names of your forms a LOT, then it will look like the best
idea you ever had.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top