- Version
- Download 253
- File Size 392.58 KB
- File Count 1
- Create Date March 1, 2016
- Last Updated March 1, 2016
Print Records from Database in Visual Basic
Print Records from Database in Visual Basic
This is a step by step tutorial on how to create a print function in vb6, the records are stored in ms access database and will be printed in a data report.
Source code of the program is also included in the download file.
Sample Print Function in Visual Basic:
Private Sub cmdPrintAll_Click()
If rs.State = adStateOpen Then rs.Close
sql = " SELECT tblStudent.ID, tblStudent.studentName, tblStudent.studentAge, tblStudent.studentContact, tblStudent.studentAddress" & _
" From tblStudent" & _
" GROUP BY tblStudent.ID, tblStudent.studentName, tblStudent.studentAge, tblStudent.studentContact, tblStudent.studentAddress" & _
" ORDER BY tblStudent.ID;"
rs.Open sql, conn
If rs.RecordCount > 0 Then
Set rptList.DataSource = rs
rptList.Show 1
Else
MsgBox "No record(s) to print", vbInformation, ""
End If
End Sub