Look at the DLookup Function.
MyVariable = DLookup("FieldName",TableName","AnotherField = 'SomeValue'")
Let me know if you need more help.
May God bless you beyond your imagination!
Lonnie Johnson
ProDev, Professional Development of MS Access Databases
Visit me at ==> http://www.prodev.us
----- Original Message ----
From: bryan.leggo <[EMAIL PROTECTED]>
To: [email protected]
Sent: Friday, November 23, 2007 5:49:59 PM
Subject: [ms_access] Pulling data from tables directly into variables
I have a "Configuration table" which is intended to hold data that
might be used as global constants throught the program, modules and
forms. Each row is a different constant. I think I can write the
function to assign the data to a variable if I could only figure out
how to get the data from a particular row without creating tables or
putting a control on a form just to access the table. The table has 4
fields, namely:
Sequence = A Sequential Number
ConstName = Text that holds the Constant identifier name
ConstValue = Text that holds the Constant's actual value
As an example, a row might contain:
1, "MAIN_PATH", "C:\TEMP_PLACE\ "
To search on the key phrase "MAIN_PATH" I would want to return the
value "C:\TEMP_PLACE\ " as a TEXT result. Therefore the function would
be something like:
FUNCTION ConstLookup (sSearchText as String) AS String
So since I want to assign these before the first form is done loading
how can I use SQL to extract the one record that I want per constant
and then put the matching value ("C:\TEMP_PLACE\ " in my example) into
a global variable without using other temporary tables or unneeded
form controls?
____________________________________________________________________________________
Be a better sports nut! Let your teams follow you
with Yahoo Mobile. Try it now.
http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
[Non-text portions of this message have been removed]