Consulting

Results 1 to 3 of 3

Thread: Display CopyFromRecordset result vertically

  1. #1

    Display CopyFromRecordset result vertically

    Hello and Good day Masters, I have this vba code that copies my student grades from access database then display or print it on my excel file. It prints the grades horizontally however is it possible to display or print the output vertically?

    Here's the current output
    99 98 79 95 95 90 99 95 96

    And I want to achieve something like this one
    99
    98
    79
    95
    95
    90
    99
    95
    96


    Here's my code:
     Set db = OpenDatabase(DBLoc)
        'MsgBox "Hello " & search
        SQL = "SELECT [Dance (PE3)], [Intro to Philo], EmTech, Entrep, Pilipino, [Practical Research 1], Animation,  [Discip and Ideas], [Org & Manage]"
        SQL = SQL & "FROM [G12B Student Information]"
        SQL = SQL & "WHERE LASTNAME = '" & search & "'"
        
        
        'Execute query and populate the recordset
        Set rs = db.OpenRecordset(SQL, dbOpenSnapshot)
        
        'Copy recordset to variables then to spreadsheet
        Application.StatusBar = "Writing to spreadsheet..."
        
        If rs.RecordCount = 0 Then
            MsgBox "Name not found in the database", vbInformation + vbOKOnly, "No Data"
            GoTo SubExit
        Else
            rs.MoveLast
            recCount = rs.RecordCount
            rs.MoveFirst
            
        End If
        
        xlSheet.Range("BQ13").CopyFromRecordset rs

    Any suggestions will be greatly appreciated. Thank you very in advance.

  2. #2
    VBAX Expert Leith Ross's Avatar
    Joined
    Oct 2012
    Location
    San Francisco, California
    Posts
    552
    Location
    Cross-posted Here at Excel Forum.
    Sincerely,
    Leith Ross

    "1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG"

  3. #3
    My apologies I was not aware of cross-posting rules, anyway thank you for responding.

Posting Permissions

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