Syntax of VBA Code

K

Ken Hudson

In the macro excerpt below I am trying to test for the condition in which
four fields of a text file (Fund, CC, BOC and ACC) are concatenated together
and compared to a variable field (LookUp).
I can not get the correct syntax in the rsInput.Open statement.
Can someone tell me the correct syntax, please?
TIA.

For ILoop = 2 To NumRowsIC
LookUp = Sheets(2).Cells(ILoop, "F")
Set oConn = New ADODB.Connection
Set rsInput = New ADODB.Recordset

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPath & ";" & _
"Extended Properties=""text;HDR=NO;FMT=FixedLength"""

rsInput.Open "SELECT * FROM " & FileOpenNameVista & " where Fund & CC &
BOC & ACC = " LookUp, oConn, adOpenStatic, adLockOptimistic, adCmdText
ActiveSheet.Cells(1, 1).CopyFromRecordset rsInput
rsInput.Close
Next ILoop
 
K

Ken Hudson

I figured it out.

rsInput.Open "SELECT * FROM " & FileOpenNameVista & " where Fund + CC +
BOC + ACC ='" & LookUp & "'", oConn, adOpenStatic, adLockOptimistic, adCmdText
 

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

Similar Threads


Top