Still Problem SQL in VBA

A

Ant

Thanks for the previous help

It is still not working. It is populating the string with
the actuall SQL statement and not the result of the SQL
statement. What do I have to do to capture the return
value of a SQL statement into a string, to be used further
in code.


Basically (simplified)
I have a table with 2 columns 'Name' and 'Path' I have a
combo box where
the user selects 'Name'. I want to use 'Path' in my code.

Private Sub cmdSelectDB_Click()
Dim strName As String
Dim strPath As String
Dim strFullPath As String


strName = me.lstName.Text
strPath = "SELECT MAx(Path) FROM TblCompNamePath Where
CompanyName = " & strName
strFullPath = strPath + "\" + strFileName + "_be"

End Sub
 
R

Ron Weiner

I think you want to do is use a Dlookup(). Try

strPath = nz(dlookup("Path","TblCompnamePath","CompanyName='" & strName &
"'"),"")

Look in Access Help for the d commands (Dlookup, Dmax, etc)

Ron W
 
J

JohnFol

strPath = DMax("[Path]", "TblCompNamePath", "[CompanyName] = '" & strName &
"'")
 

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