+ Reply to Thread
Results 1 to 2 of 2

Syntax of VBA Code

  1. #1
    Ken Hudson
    Guest

    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

  2. #2
    Ken Hudson
    Guest

    RE: 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


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1