How to Select Records in a Data Report in Visual Basic 6.0

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Select Records in a Data Report in Visual Basic 6.0
Lay out data in a Visual Basic DataGrid. (number background image by kuhar from Fotolia.com)

Data reports contain a list of information visible on your Visual Basic form. These reports are held in a control called a "DataGrid." The grid lays out and formats the data for your software users, so they can scroll through each record. Each record is contained in cells, similar to the layout of an Excel spreadsheet. You can automate selection of these records using Visual Basic code. This is beneficial when you want to select default records for your users.

Skill level:
Moderate

Other People Are Reading

Instructions

  1. 1

    Set up the Excel object. The Excel object library contains the methods and properties you need to create, edit and display a spreadsheet. The following code initialises this object:

    Set excel = CreateObject("Excel.Application")

  2. 2

    Write the data to the Excel spreadsheet. You don't need to write data to display a spreadsheet, but the programmer typically enters some data to the spreadsheet before rendering it to the user. The following code writes a simple string in the first cell of the spreadsheet:

    excel.Range("A1").Select

    excel.ActiveCell.FormulaR1C1 = "Display this Spreadsheet"

  3. 3

    Display the spreadsheet to the user. The form retrieves the MIME type, which indicates that the display properties are an Excel spreadsheet. The following code clears the screen and displays the spreadsheet to your reader:

    response.Clear()

    response.Charset = ""

    response.ContentType = "application/vnd.ms-excel"

    response.Flush()

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.