Results 1 to 10 of 10

Error in Displaying data fetched from a table

Threaded View

  1. #1
    Registered User
    Join Date
    03-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    24

    Post Error in Displaying data fetched from a table

    Hi Guys,

    I am facing issues while displaying data fetched from an excel table. The data is fetched dynamically through a loop and I want them to be displayed in other table in the same workbook. The code snippet is mentioned below:

    Private Sub cmdExtract_Click()
    Dim i, old_count As Integer
    i = 0
    old_count = 0
    For Each chk In ActiveSheet.CheckBoxes
    If chk.Value = 1 Then
           myArray(i) = chk.Caption
           i = i + 1
           End If
    Next chk
       
    Select Case cmbDatagroups.Value
                    
    Case "Insight"
        
        With ActiveWorkbook.Sheets
        .Add after:=Worksheets(Worksheets.count)
        End With
        ActiveSheet.Name = "Insight_records"
        insightFlag = True
        For i = 0 To UBound(myArray)
        strSQL = "select * from [AGE_INSIGHT$] where [Scenario ID]= '" & myArray(i) & "' "
        closeRS
        OpenDB
        rs.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
        old_count = old_count + rs.RecordCount
        ActiveCell.CopyFromRecordset rs
        Next
        
    End Sub
    ****************

    The AGE_INSIGHT is the table from where I am fetching the data based on some Scenario ID's.

    But currently only the last Scenario Id present in the recordset is getting displayed in the output. i.e say if scenario id's IN0000001 and IN000002 are selected then the data of IN000002 is only displayed in the output.

    All the excel guru's out here please help.
    Last edited by Leith Ross; 04-28-2013 at 01:45 PM. Reason: Added Code Tags

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