data into vba

D

Dazzadata

simplest question ever but how do you get a value from a table into vba.

I want to put a path into a table as a constant, get vba to pick this up and
use the transferspreadsheet cmd to load a series of data rows into a table

works like a charm but at the minute the path is put in using an inputbox

cheers
 
D

Douglas J. Steele

Simplest way would be to use DLookup:

Dim strFilePath

strFilePath = DLookup("[NameOfField]", "[NameOfTable]")


That assumes that the table only has one row in it. If there's more, you can
specify a Where clause as the third argument:

strFilePath = DLookup("[NameOfField]", "[NameOfTable]",
"[SomeField]='SomeValue'")
 
P

Paolo

Hi Dazzadata,
if in your table you have just the row with the path you can use a dlookup
without criteria. e.g. (in the sample I name the field with the path yourpath
and the table containing it yourtable. you'll have to substitute those names
with the correct one)

the_path=dlookup("yourpath","yourtable")

HTH Paolo
 

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