VB6 and Access 2002 problem.

Posted on 2004-11-17
Last Modified: 2010-05-03
 Hello experts!
  I'm using VB6 and Access 2002 for my database development. In my program, I want to display report and I think Access Report may solve the problem. I search experts-exchange and I find the code:

Public app As Application
Set app = New Access.Application
app.OpenCurrentDatabase "C:\db1.mdb"
app.DoCmd.OpenReport "EmpReport", acViewPreview

  But nothing happen after I run this code, do you know how to fix this? And, I want the report will be displayed in my App, not in the Access window, how can I do this with VB6 and Access 2002? If at my user machine, only older Access version is installed, will my program run properly?

  Thank you.
Question by:dttri
    LVL 48

    Expert Comment

    app.DoCmd.Maximize is VBA not vb6
    LVL 10

    Expert Comment

        Have a look at the code, the person is manipulating Access (via VBA) through VB6, or at least this was the attempt.

        Is your database located in the directory "C:\" with a name of "db1.mdb"?
        Do you have a Report named "EmpReport" in that database?

        As for making the Report open in VB6 and not Access, that's not possible, it has to use Access since it is an Access Report.  Have you considered just using a Data Report in VB6?  Or maybe even Crystal Reports?

    LVL 7

    Author Comment

    >>Is your database located in the directory "C:\" with a name of "db1.mdb"?
    Yes, it is.
    >>Do you have a Report named "EmpReport" in that database?
    Yes, it have.
    LVL 7

    Author Comment

     I also notice that, after run these commands, although Access or report don't appear, I see Access in the Task Manager (process tab). Do you have any suggestion?
      Thank you.
    LVL 10

    Accepted Solution

    ok, I don't have VB6 in front of me, but it looks like the problem is that you forgot to make the object visible.

    It'll be something like this:
    app.Visible = True

    Put that after the line that opens the Report and you should be fine.

    Give that a try and you should see the report come up.

    LVL 7

    Author Comment

     Thanks very much! The report appear!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now