VB Code:
  1. Option Explicit
  2. 'ADD REFERENCE TO MS ACCESS XX.X OBJECT LIBRARY
  3. 'ADD ONE (1) COMMAND BUTTON (Command1)
  4. 'EXAMPLE WILL CREATE A NEW DATABASE AND A NEW REPORT WITH ONE TEXTBOX AND A LINKED LABEL
  5. Private Sub Command1_Click()
  6.  
  7.     Dim oApp As Access.Application
  8.     Dim oReport As Access.Report
  9.     Dim oLabel As Object
  10.     Dim oTextBox As Object
  11.    
  12.     If Dir("D:\RobDog888.mdb", vbArchive Or vbNormal Or vbHidden Or vbReadOnly) <> "" Then
  13.         Kill "D:\RobDog888.mdb"
  14.     End If
  15.     Set oApp = New Access.Application
  16.     oApp.NewCurrentDatabase "D:\RobDog888.mdb"
  17.     oApp.Visible = True
  18.     Set oReport = oApp.CreateReport
  19. '    oReport.RecordSource = "qrySomeQuery"
  20.     oReport.LayoutForPrint = True
  21.     oReport.Caption = "MyReport"
  22.     Set oTextBox = oApp.CreateReportControl(oReport.Name, acTextBox, acDetail, "", "", 1560, 1500, 1000, 250)
  23.     Set oLabel = oApp.CreateReportControl(oReport.Name, acLabel, acDetail, oTextBox.Name, , 500, 1500, 1000, 250)
  24.     oTextBox.Properties(1).Value = "txtTextBox"
  25.     oTextBox.Properties(3).Value = "My Text"
  26.     oLabel.Name = "lblLabel"
  27.     oLabel.Caption = "My Label"
  28.     DoCmd.Maximize
  29.     oApp.RunCommand acCmdPrintPreview
  30.     'oReport.Print
  31.    
  32. End Sub