Should I store constants in a table?

B

BC

I am assembling an accounting type database in which I will be printing
many reports.
Some of the information in the reports will be things like addresses,
names, etc. that are relative constant but contained on may reports;
they may change occasionally.
I was planning on placing them in a table and using a form for editing.
It occurred to be that I may have more than one record in the table ...
I am not sure how to address a particular record when retrieving it for
my reports.
Am I on the wrong or right trail?
 
D

Douglas J. Steele

Storing pseudo-constants in a table is a valid approach.

One way to retrieve them is to use DLookup. Assuming your table is named
tblConstants, and it has 2 fields ConstantName and ConstantValue, try
something like:

DLookup("ConstantValue", "tblConstants", "ConstantName = 'CompanyName'")

Note that that's "ConstantName = ' CompanyName ' " as the 3rd parameter. If
you want to use a variable to specify the name of the constant, you'd use

DLookup("ConstantValue", "tblConstants", "ConstantName = '" &
strConstantName & "'")

Now, the 3rd parameter is "ConstantName = ' " & strConstantName & " ' "

(unless strConstantName can contain an apostrophe, in which case use
"ConstantName = " & Chr$(34) & strConstantName & Chr$(34))
 

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