View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Hudson Ken Hudson is offline
external usenet poster
 
Posts: 186
Default Syntax of VBA Code

I figured it out.

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


--
Ken Hudson


"Ken Hudson" wrote:

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
--
Ken Hudson