Results 1 to 4 of 4

Thread: Generating and loading report

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow Generating and loading report

    Hi every body. I wonder how i can generate and load a report when a button is clicked on access 2000 form. I be happy if some one show me an example.Thanks

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

    Re: Generating and loading report

    If it is directly in Access then it's quite simple:
    VB Code:
    1. 'place command button on the form, dblclick on it
    2. 'and assign some event procedure similar to the following
    3.  
    4. Sub Button1_Click()
    5.     DoCmd.OpenReport "Employee Sales by Country",acViewPreview
    6. End Sub
    If you need to run report from outside the Access (say from VB6 application) then you'll have to do automation. Here is a quick sample:
    VB Code:
    1. Public Sub RunAccessReport(strDB As String, strReport As String, _
    2.                            Optional strFilter As String = "", _
    3.                            Optional strWhere As String = "")
    4. '===================================================================
    5. Dim AccessDB As Object
    6.  
    7.     Set AccessDB = CreateObject("Access.Application")
    8.     AccessDB.OpenCurrentDatabase strDB
    9.     AccessDB.DoCmd.OpenReport strReport, acViewPreview, strFilter, strWhere
    10.     AccessDB.Visible = True
    11.     Set AccessDB = Nothing
    12.  
    13. End Sub

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow Re: Generating and loading report

    Quote Originally Posted by RhinoBull
    If it is directly in Access then it's quite simple:
    VB Code:
    1. 'place command button on the form, dblclick on it
    2. 'and assign some event procedure similar to the following
    3.  
    4. Sub Button1_Click()
    5.     DoCmd.OpenReport "Employee Sales by Country",acViewPreview
    6. End Sub
    If you need to run report from outside the Access (say from VB6 application) then you'll have to do automation. Here is a quick sample:
    VB Code:
    1. Public Sub RunAccessReport(strDB As String, strReport As String, _
    2.                            Optional strFilter As String = "", _
    3.                            Optional strWhere As String = "")
    4. '===================================================================
    5. Dim AccessDB As Object
    6.  
    7.     Set AccessDB = CreateObject("Access.Application")
    8.     AccessDB.OpenCurrentDatabase strDB
    9.     AccessDB.DoCmd.OpenReport strReport, acViewPreview, strFilter, strWhere
    10.     AccessDB.Visible = True
    11.     Set AccessDB = Nothing
    12.  
    13. End Sub

    Thank u for u reply. is your code all in in access 2000 and vba? i want to generate and load same report from withing access.Thanks

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

    Re: Generating and loading report

    I don't know how to explain and/or present any better but I did give you exact answer you're looking for so read it through my post once again and try to determine what's for 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