1 / 20

CIS 338: Printing

CIS 338: Printing. Dr. Ralph D. Westfall February, 2003. Create Print Reports 2 Ways. place fields on report layout manually interface is relatively easy to use or use retrieve structure automated layout easier to create summary fields such as subtotals within the report

xanto
Download Presentation

CIS 338: Printing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CIS 338: Printing Dr. Ralph D. Westfall February, 2003

  2. Create Print Reports 2 Ways • place fields on report layout manually • interface is relatively easy to use • or use retrieve structure automated layout • easier to create summary fields such as subtotals within the report • makes it difficult to use code to get information from data source

  3. Manual Report Layout • start new project • Project>References>Microsoft ActiveX Data Objects 2.[ ] Library, OK • Project>Components>Designers>Data Report, OK • add command button to form • double click button and add code

  4. Manual Report Layout Code Dim cn As ADODB.Connection 'General Set cn = New ADODB.Connection 'Form_Load cn.ConnectionString = _ "Driver=Microsoft Access Driver (*.mdb);DBQ="_ & App.Path & "\[yourdatabase].mdb;" cn.Open dbquery2000.mdb

  5. Manual Layout Code - 2 Dim sSQL As String 'General Dim rs As New ADODB.Recordset 'Command1_Click() sSQL = "select * from Payments where Date > #6-30-00#" Set rs = cn.Execute(sSQL)

  6. Adding a Data Report • Project>Add Data Report • Data Report toolbox & Properties windows • Data Report Designer window parts • Report Header – titles etc. for whole report • Page Header – headings etc. for each page • Detail – data in report for each record • Page Footer – at page bottoms • Report Footer - after last report lines

  7. Designing a Data Report • click RptLabel (tool) and draw on report • put label information into Caption property • click RptTextbox and draw on report • put name of a field in database into DataField property for each RptTextbox BldgNo AcctNo Payment

  8. Data Report Code 'Command1_Click() Set DataReport1.DataSource = rs DataReport1.Show • run project and view report • note Print button at top of report • also Export button: save as HTML or text 'Notes

  9. Enhancing a Data Report • what needs to be fixed? • make changes in layout, as necessary • can change RptTextBox and Label Font • click and drag Section boundaries to tighten spacing • move RptTextBoxes and Labels to fit into new boundaries

  10. Enhancing a Data Report - 2 • special characters for label Captions • %p – current page number • %d – current short date (mm/dd/yy) • other date formats available • %t – current military time (e.g., 14:20) • other time formats available • %i – Title property of DataReport object • etc. 'p. 649

  11. Enhancing a Data Report - 3 • RptImage (tool) to place image on page • click Picture property to identify source file • RptLine to draw lines on page • RptShape to draw geometric figures • Shape property identifies type of figure

  12. Enhancing a Data Report - 4 • RptFunction (tool) adds summary fields • DataField property = database field name • FunctionType property for type of data • RptFuncSum, …Ave(rage) • …Min(imum), …Max(imum) • …RCnt – record count • etc. 'p. 652

  13. Enhancing a Data Report - 5 • putting a variable into a header (p. 647) Dim strFirstDate strFirstDate = "10-30-02" DataReport1.Sections("Section4").Controls_("lblHeader").Caption = strFirstDate • put this code before DataReport1.Show • headers: Section4=report, Section2=page (or names you changed to) • lblHeaderis Name of a label control

  14. Enhancing a Data Report - 6 • Crystal Reports packaged with VB • much more control over appearance • need to install Crystl32.exe from Visual Studio CD • runs from Add-Ins>Report Designer • very old version of Crystal Reports (4.6 or ?)

  15. Automated Report Layout • Project>References>Microsoft Data Environment Instance 1.0>OK • may need to install SP4 to get this • Project>Components>Designers>Data Environment, OK • Project>Add Data Environment • right click Connection1 in Environment • set Provider to Microsoft Jet 4.0 OLE DB • browse for database name in Connection

  16. Automated Report Layout - 2 • right click Connection1 >Add Command • right click Command1 >Properties • Database Object = View for query or Table • Object Name = QueryTotalDetail • Grouping tab • check Group Command Object • select BldgNo, SumOfPayment, click > , then click OK

  17. Automated Report Layout - 3 • Project>Add Data Report • DataSource = DataEnvironment1 • DataMember=Command1_Grouping • right-click DataReport2 • click Retrieve Structure, Yes • Warning: destroys any previous layout and controls on this form

  18. Automated Report Layout - 4 • tile Data Environment and DataReport2 • in the Data Environment, click on the plus sign (+) for the Summary fields in Command1_Grouping • click/drag BldgNo from Summary fields to DataReport2 Group Header • SumOfPayment -> Group Footer

  19. Automated Report Layout - 5 • click and drag Detail field(s) into DataReport2 Detail e.g., Payment • note that you get 2 controls: label and text box • if necessary, use Ctrl key to select textbox and move away from label

  20. Automated Report Layout - 6 • add another command button to form • put code in button's click event DataReport2.Show • run project and view report 2 • make changes in layout as necessary

More Related