Reading first record from a table

  • Thread starter Thread starter Max Moor
  • Start date Start date
M

Max Moor

Hi All,
I have a table "tblSystemSettings." The plan is to put settings I
want to keep around in there. It will only ever have one record, with
however many fields as I have settings.

It ought to be a simple matter to read any one field, like
"idxCurrentUser," out of there in VB code, but I can't figure out how.
I've looked through help, and tried all kinds of shotgun approaches, but I
haven't hit on it.

Can someone give me the proper syntax?
 
=DLookup("idxCurrentUser", "tblSystemSettings")

Hi Allen & Van,

Thanks for getting back to me so quickly.

I actually knew about the DLookup. I should have said so in my
posying. Honestly, I don't know a good reason not to just call the
function. It's not like there's an enormous amount of overhead the way I'd
be using it.

I was thinking there was a shortcut using parenthesis in fancy way.
I sort of got stuck on doing it that way, after not being able to find a
reference on those kinds of syntax shortcuts. Frustration made it a
challenge. :-)

Thanks, Max
 
I actually knew about the DLookup. I should have said so in my
posying. Honestly, I don't know a good reason not to just call the
function. It's not like there's an enormous amount of overhead the way I'd
be using it.

With only one record in the table, there would be virtually no "overhead"
involved. The disadvantage in using aggregate domain functions is seen when
there are a large number of records in the target recordset (query or table)
because those functions don't take advantage of indexes. In those cases, opening
recordsets in memory and limiting the rows returned through select statements
containing criteria can dramatically increase performance.
 
If you already have a recordset, you can read
an arbitrary field 's' or 'n' like this:

v = rs.fields(s)
v = rs.fields(n)

Also,

For system settings that are called repeatedly, it may
make sense to cache in VB variables/a collection/an Array.

Access is a general purpose multi-user database system,
and although you may have data that you know is static and
frequently used, Access will still try to flush and
refresh the recordset: If you don't need that you can
manage the data separately.

(david)
 
Back
Top