Results 1 to 3 of 3

Thread: i want to access a report ina database from my vb forms

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    9

    i want to access a report ina database from my vb forms

    hi

    i have created some forms in visual basic and i wanted to create a command button to access a report in my Access Database

    how do i do this??
    Last edited by jasmine; May 7th, 2008 at 03:19 PM.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: i want to access a report ina database from my vb forms

    The only way is if you automate MS Access (that means MS Access must be installed on user's machine).
    Here is a quick sample - make changes as necessary.
    Code:
    Public Sub RunAccessReport(strDB As String, strReport As String, _
                               Optional strFilter As String = "", _
                               Optional strWhere As String = "")
    '===================================================================
    Dim AccessDB As Object
    
        Set AccessDB = CreateObject("Access.Application")
        AccessDB.OpenCurrentDatabase strDB
        
        AccessDB.DoCmd.OpenReport strReport, acViewPreview, strFilter, strWhere
        AccessDB.DoCmd.PrintOut acPrintAll
        
        '''AccessDB.DoCmd.PrintOut acPages, 1, 1
        
        '''AccessDB.Visible = True
        Set AccessDB = Nothing
    
    End Sub
    
    'sample usage:
    RunAccessReport App.Path & "\mydb.mdb", "Report1"

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: i want to access a report ina database from my vb forms

    Moved to Reporting

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