Results 1 to 2 of 2

Loop through range of cells and return price in SQL query

Threaded View

  1. #1
    Registered User
    Join Date
    11-18-2016
    Location
    Stockholm
    MS-Off Ver
    2016
    Posts
    1

    Loop through range of cells and return price in SQL query

    Hi,

    I use the following code to search for article numbers in a textfield on a form, in a sql database and return the price.
    But what If I would like to search for serveral article numbers at the same time from a range of cells on the active sheet and return all prices and print them on the same row as each article number but in a different column?

    Would much appreciate the help!

    'Query
        SQLStr = "SELECT convert(money, poCost) FROM [dbo].[AVKParmenItemExportItemNoBid] WHERE MfrPartNbr LIKE '%" & txtProdDescr.Value & "%'"
         
        Set Cn = New ADODB.Connection
      
        With Cn
            .CursorLocation = adUseClient
            .Open "Driver={SQL Server};Server=" & Server_Name & ";Database=" & Database_Name & _
        ";Uid=" & User_ID & ";Pwd=" & Password & ";"
         
        Set rs = .Execute(SQLStr)
        End With
         
        With rs
        
            Set .ActiveConnection = Nothing 
            K = .Fields.Count '
            r = .RecordCount
        
            vaData = .GetRows
        End With
      
        rs.Close
        Cn.Close
    Last edited by Rödtjut; 01-20-2017 at 02:39 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 08-27-2014, 05:05 PM
  2. [SOLVED] Lookup Code and return Price from Price Band
    By PaulHAG in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 06-16-2014, 11:06 AM
  3. [SOLVED] Loop over all queries and return first column of each query in consolidated table
    By learning_vba in forum Access Tables & Databases
    Replies: 2
    Last Post: 01-03-2014, 10:19 AM
  4. Replies: 1
    Last Post: 07-24-2013, 12:13 PM
  5. [SOLVED] Query Oracle using range in Excel to return individual records for each cell in range
    By bigwillydier in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-18-2013, 06:37 PM
  6. Replies: 1
    Last Post: 07-03-2011, 05:12 PM
  7. Replies: 8
    Last Post: 08-06-2010, 07:27 AM

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