Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Search Results from DBGrid

Status
Not open for further replies.

Linguist

Technical User
Jul 11, 2000
40
0
0
US
I have written an ADO-based front-end to an MS Access database. The database is displayed in a datagrid format. After the user makes a query, the resulting "hits" are displayed in the datagrid. Next, the user clicks on each record (row in the datagrid) that he wants to print out. Then he clicks the Print button. Here is the code that is activated:

Code:
Public Sub Print_Click()

Dim rst As Recordset
Dim varRecords As Variant
Dim intRows As Integer
Dim intNumReturned As Integer, intNumFields As Integer
Dim intField As Integer, intRecord As Integer

Printer.Print ""
Printer.FontName = "Arial"
Printer.FontSize = 12
Printer.FontBold = False

intRows = grdDataGrid.SelBookmarks.Count - 1
Set rst = datPrimaryRS.Recordset
varRecords = rst.GetRows(intRows)
intNumReturned = UBound(varRecords, 2)
intNumFields = UBound(varRecords, 1)
For intRecord = 0 To intNumReturned
    For intField = 0 To intNumFields
       Printer.Print varRecords(intField, intRecord)
    Next intField
  Printer.Print
Next intRecord
Printer.EndDoc
intRows = 0
End Sub

Now, here is the problem: the marked records (rows) are not printed.

Any suggestions would be very much appreciated.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top