Download presentation
Presentation is loading. Please wait.
1
Active X EXE (Out of Process Components)
Please see speaker notes for additional information! This out of processed component will print a report.
2
Select ActiveX EXE when creating an Out-of-Process Component
Select ActiveX EXE when creating an Out-of-Process Component. The results are shown. The project that we are creating will be the process to print. This is out of process which means we will have a button on the form in another project that requires printing. This project will print while other processing is going on.
3
Option Explicit Private SADBI As SavAcctDBI Private SA As SavAcct Not used. Private Sub Class_Initialize() Set SADBI = New SavAcctDBI End Sub Private Sub Class_Terminate() Set SADBI = Nothing Private Sub PrintLine(vPrntLine As String) Static LineCnt As Integer Printer.Print vPrntLine LineCnt = LineCnt + 1 If LineCnt = 50 Then Printer.NewPage LineCnt = 0 End If The SavAcct Class Modules (different name because I did it at a different time) makes all of my class modules available to this project. You can see that under Project/References SavAcct Class Modules has been checked. Remember SavAcctDBI is the interface between the database and the program. Printer is an object that can have methods such as the Print method which prints a line or the NewPage method which advances to a new page.
4
This line continued below.
Public Sub PrintAllAccounts() On Error GoTo PrintAllError With SADBI If .Count > 0 Then Dim i As Long Dim LineCnt As Integer Printer.NewPage For i = 0 To .Count - 1 Dim PrntAcct As SavAcct Set PrntAcct = .Item(i) With PrntAcct Dim AcctLine As String PrintLine vbCrLf AcctLine = .AccountNumber & " " & .Balance & " " & .IntRate PrintLine AcctLine With .Transactions Dim j As Long For j = 0 To .Count - 1 Dim objDsplyTran As Transaction Set objDsplyTran = .Item(j) With objDsplyTran Dim TranLine As String TranLine = vbTab & vbTab & .AccountNumber & " " & .TransactionNumber PrintLine TranLine End With Next j End If Next i Printer.EndDoc Exit Sub PrintAllError: MsgBox Err.Number & " " & Err.Description & " " & vbCrLf & Err.Source End Sub This line continued below. I will look at this in more detail on the next slides. & " " & .TransactionType & " " & .TransactionAmount
5
With SADBI If .Count > 0 Then Dim i As Long Dim LineCnt As Integer Printer.NewPage For i = 0 To .Count - 1 Dim PrntAcct As SavAcct Set PrntAcct = .Item(i) With PrntAcct Dim AcctLine As String PrintLine vbCrLf AcctLine = .AccountNumber & " " & .Balance & " " & .IntRate PrintLine AcctLine With .Transactions Dim j As Long For j = 0 To .Count - 1 Dim objDsplyTran As Transaction Set objDsplyTran = .Item(j) With objDsplyTran Dim TranLine As String TranLine = vbTab & vbTab & .AccountNumber & " " PrintLine TranLine End With Next j End If Next i Printer.EndDoc After AcctLine is set up, it is passed to the PrintLine procedure to be written. See the previous slide for the complete layout of TranLine. This report produces all of the accounts with all of the transactions under the appropriate account. vbTab is used to tab in for the transactions. etc After TranLine has been set up, it is passed to the PrintLine procedure to be written.
6
Make SavAcctPrnt01.exe creates and executable that can be used by other projects.
SavAcct Printer Component is the result of the make executable. You can see SavAcctPrnt01.exe shown as the location. The name SavAcct Printer Componet was the result of accessing the Project Properties and setting Project Description to that name.
7
This is the project that I am going to execute
This is the project that I am going to execute. It uses my class modules SavAcct Class Modules and it also uses my SavAcct Printer Component that was created on the previous slides. Note that it is the same form we have been using but I added a Print Accounts button.
8
When Print Accounts is clicked, the code in cmdPrntAccts_Click() is executed.
Set to nothing first in case it all ready exists. PrintAllAccounts in the SavAcctPrnt class that was shown on previous slides.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.