Default Values

  • Thread starter Thread starter David C. Holley
  • Start date Start date
D

David C. Holley

I am currently using a multi-purpose function to retrieve a default
value from a table containing th values. (The function uses DLookup() to
grab the correct value.) As I seem to recall, someone mentioned the idea
of using a class module to load up the values when then front end opens
and then store them in global variables until needed. Does that sound
familar or is my memory starting to go?
 
Hi David,

that would not be a good idea as memory variables are
susceptibile to being lost -- you should not count on them
being there the whole time your db is open.

you can use

currentdb.TableDefs("Tablename").fields("Fieldname").properties("defaultvalue")

Warm Regards,
Crystal
MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
strive4peace said:
Hi David,

that would not be a good idea as memory variables are
susceptibile to being lost -- you should not count on them
being there the whole time your db is open.

One way to get around this is to create the variables as public
properties in a standard module, with a private variable that holds the
value retrieved from the table via DLookup. In the Property Get
routine, you return the value from the private variable if it has been
loaded (which is most of the time), and look up the value in the table
when it hasn't (and set the private variable so it's there in memory
next time). That way, you only have to go to the table if the private
variable is not set, whether because it's the first reference or because
the VB project has been reset.
 
Back
Top