data into vba

  • Thread starter Thread starter Dazzadata
  • Start date Start date
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
 
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'")
 
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
 
Back
Top