My challenge this week is to find a better more efficient method of implementing lines of code that work. We have built in the ability for a user to “rename” captions and/or labels in reports and forms. I am not sure this is the best method of design, so I am open to suggestions. The following works, but seems inefficient and is cumbersome when adding new forms or reports to the database.
I have a table (tblLabels) with three fields
pkey (Primary Key)
strName (not editable by user)
strValue (user defined)
There are three records,
“1”,”label1″,”Region”
“2”,”label2″,”Building”
“3”,”label3″,”Room”
where Region, Building and Room are how one user has his set up, but other users use names other than the three mentioned.
The idea is to use tblLabels table to define the labels on forms and reports, giving each user the opportunity to assign a name to each of the three labels that fit her/his needs. In other words on a given form or report, the control caption would be Region, Building, Room for label1, label2, label3, respectively, for a person using the above table records. However, other users use copies of this database and change the names of the strValue in the tblLabels table to match their needs.
Right now, we have code on the “On Load” event that dimensions the variables, creates a recordset, reads the values into the recordset and assigns them to the controls. It works fine, but to me that seems like an inefficient method as every form and every report that use the labels, has to have the same code in the “OnLoad” event. Is it possible to create a function, class or module that could be run on start up that would load these variables one time and not every time a form or report is run?
Is there a better way to implement?
Thanks in advance for your ideas and suggestions.
Ken