1

I am trying to reference a particular field from a table within a function call. Specifically, I would like to open an executable and get the path from the table. Here, the path is hardcoded in:

    Shell(“C:\ECLIPSE_CPP\eclipse.exe”)

However, I would like to store the path within a table and call a function (maybe the Shell function?) on a path from that table.

This is what I have tried:

    strSQL = “SELECT Path FROM Paths WHERE Tool = “”Eclipse””;”
    Shell(strSQL)

The Paths table looks like this:

 
    Tool    | Path
    ========|=============================
Eclipse | “C:\ECLIPSE_CPP\eclipse.exe”

Does anyone know way to reference this table value in VBA code?

2 Answers 2

2
strPath = DLookup("Path" , "Paths" , "Tool = 'Eclipse'")
Shell(strPath)

DLookup is not efficient. It may be fine for your purpose, but if not, you can use a recordset to retrieve the value.

Sign up to request clarification or add additional context in comments.

Comments

2
Dim dbs as DAO.Database
Dim rs as DAO.Recordset
Dim strpath as String

Set dbs = CurrentDb
Set rs = dbs.OpenRecordset("Select Path from Paths where Tool = 'Eclipse'")

strpath = rs.Fields(0)
    '   = rs!Path       alternative
    '   = rs("Path")    alternative

Application.FollowHyperlink(strpath)

1 Comment

Upvote -- nice answer for recordset code, and even an Application function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.