Results 1 to 3 of 3

Thread: Access Report

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2004
    Posts
    8

    Exclamation Access Report

    can we use Aceess Report in VB6 Application if yes then How

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Junior Member
    Join Date
    Dec 2004
    Posts
    29

    Re: Access Report

    Is there any code that will do the same in VB.NET. also the statement
    Dim oApp As Access.Application gives me an error stating that it is not defined and i have not idea whats wrong

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width