![]() |
Syntax of VBA Code
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 |
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 |
All times are GMT +1. The time now is 03:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com