Read value from table (1 Viewer)

ejhatch

Registered User.
Local time
Yesterday, 20:25
Joined
Oct 12, 2005
Messages
26
Hi All,

I know this will appear in a thread somewhere but I have searched in vain. I need to be able to read a value from a table. If the table looks as follows:

Name Text

default file path C:\temp

I am trying to get the code to find the record "Default file path" in the table called "settings" and then to return the actual value "c:\temp"

This record is not the only record in the table. There are many records.

Any guidance would be most grateful.

Thanks,

Evan
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:25
Joined
Feb 19, 2002
Messages
43,565
I can't tell the context of this question so I'll show you a query that will return the desired record.

Select [Text] From YourTable
Where [Name] = "default file path";

PS both Text and Name are property names and can easily cause problems with VBA.
 

Jura

New member
Local time
Today, 05:25
Joined
Feb 14, 2006
Messages
7
Hi ejhatch,

You can use the command dlookup to search in tables.

Code:
Dim varX As Variant
varX = DLookup("[Text]", "YourTableName", "[Name] = 'default file path' ")

Becare full with using colom names like "Name" and "Text"
 

ejhatch

Registered User.
Local time
Yesterday, 20:25
Joined
Oct 12, 2005
Messages
26
Hi,

Thanks for your prompt replies and advice on the choice of names etc. I changed the names to make it more simple.

Basically I am running the code in a form and wish to assign a value to a variable. I need the code to go to a specific table, go down the first column till it finds a specific entry in that column and then return the value which is held adjacent to it in column 2. This value held in column 2 could be any value.

I have used the replies and they give me the desired result.

Thanks a stack,

Evan
 

Users who are viewing this thread

Top Bottom