Home
SEARCH

 

Using the TAL Bar Code ActiveX Control with a VB Data Report


Adding Bar Codes to the Report

Open frmShowReport and make it the Startup Object for the Project. Resize it to be about 5700 High x 7000 Wide. From the Data Environment, drag the Customers Command onto the form. This will create text boxes and lables for all of the fields in the Customers table. Move them into position on the form.

Next add the TAL Bar Code control to the project and the form. To add it to the project click on Components and select it from the list:

Then draw it onto the bottom of the form. Set the Symbology Property to 8 - bcPostNET. Set the Data Bindings properties as follows, then click OK:

Next we need to add some buttons to allow us to navigate through the records and to display the report. Add 7Command Buttons and a text box with the following Properties:

Control Name Caption
cmdFirst |<
cmdLast >|
cmdNext >
cmdPrevious <
cmdExit Exit
cmdReport Preview
cmdPrintAll Print All
txtPosition  

Your form should now look something like this:

Now it needs some code:

 

Sub Position()
'******** Code in this section pertains to updating position display **********
  frmShowReport.txtPosition.Text = "Record " & deNwind.rsCustomers.AbsolutePosition & _
" of " & deNwind.rsCustomers.RecordCount
End Sub

Private Sub cmdPrevious_Click()
'******** Code in this section pertains moving to previous record **********
  deNwind.rsCustomers.MovePrevious
  If deNwind.rsCustomers.BOF Then
    deNwind.rsCustomers.MoveNext
  End If
  Position
End Sub

Private Sub cmdNext_Click()
'******** Code in this section pertains moving to next record **********
  deNwind.rsCustomers.MoveNext
  If deNwind.rsCustomers.EOF Then
    deNwind.rsCustomers.MovePrevious
  End If
  Position
End Sub

Private Sub cmdLast_Click()
'******** Code in this section pertains moving to last record **********
  deNwind.rsCustomers.MoveLast
  Position
End Sub

Private Sub cmdFirst_Click()
'******** Code in this section pertains moving to first record **********
  deNwind.rsCustomers.MoveFirst
  Position
End Sub

Private Sub cmdExit_Click()
'******** Code in this section pertains to closing the application **********
  Unload Me
End Sub

Private Sub cmdReport_Click()

  ' Make sure we have the latest info
  deNwind.rsCustomers.Requery

  ' Assign values to the labels in the report based on the current record
  ' displayed on the form

  With rptNwind
    .Sections("ReportHeader").Controls("lblContact").Caption = frmShowReport.txtContactName.Text
    .Sections("ReportHeader").Controls("lblCompany").Caption = frmShowReport.txtCompanyName.Text
    .Sections("ReportHeader").Controls("lblAddress").Caption = frmShowReport.txtAddress.Text
    .Sections("ReportHeader").Controls("lblCity").Caption = frmShowReport.txtCity.Text
    .Sections("ReportHeader").Controls("lblRegion").Caption = frmShowReport.txtRegion.Text
    .Sections("ReportHeader").Controls("lblZip").Caption = frmShowReport.txtPostalCode.Text
    .Sections("ReportHeader").Controls("lblCountry").Caption = frmShowReport.txtCountry.Text

'set the picture box to the picture property of the ActiveX

    Set .Sections("ReportHeader").Controls("ImgBc").Picture = frmShowReport.TALBarCd1.Picture
'.Orientation = rptOrientPortrait 'rptOrientLandscape
'.PrintReport True

    .Show 'show the report
  End With
End Sub

Private Sub Form_Load()
  Position
End Sub


Previous Page

Back to Code Samples