SQL in VBA??

A

Ant

Hi All

This seems very simple and I am a bit embarassed that I am
having trouble with it. I know I have done it before but
cant remember the exact format that works.
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

* What is the best way to refer to a string in an SQL
statement in Code?

I have simplified this but it should give you an idea of
what I want to do and where I am going wrong.

Ant
 
T

TPratt

strPath = "SELECT MAx(Path) FROM TblCompNamePath Where
CompanyName = " & *strName
 
J

JohnFol

You need to delimit the string within the QQL
strPath = "SELECT MAx(Path) FROM TblCompNamePath Where CompanyName = '" &
*strName &"'"

and

strFullPath = me.lstName.Text + "\" + strFileName + "_be"
 

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