Solved

Access reports in VB

Posted on 2002-05-15
9
243 Views
Last Modified: 2013-11-28
Is it possible to 'use' access reports through VB?

can you open access and get the report open in print preview mode, or is there some way to do it without opening access? (i.e. a seperate report viewer/printer program hidden somewhere)

simple! but i still cant seem to do it :|

SiM99
0
Comment
Question by:SiM99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7011556
it is not possible because the reports need to be runned by the Access engine. The only way is to rebuild your reports using a real reporting engine (Crystal Report, Active Report, ...)
0
 
LVL 1

Expert Comment

by:carpediem
ID: 7011653
I have just been having the same issue.  emoreau is right that you need the Access engine which means Access will have to be installed on any PC running the VB app that launches the report (which is a real pain for me).

Here is the code I am using until I can find something better.

                Set lAccess = CreateObject("Access.Application")
                               
                Set db = lAccess.Application.DBEngine.Workspaces(0).OpenDatabase(IPDBNAME, 0, False, ";pwd=X1JFH9")
                lAccess.Visible = False
                lAccess.OpenCurrentDatabase IPDBNAME, False
                Set db = Nothing
               
                lintResult = SetForegroundWindow(lAccess.hWndAccessApp)
                'The report should open in printpreview
                If RptDest = 0 Then
                    lAccess.DoCmd.OpenReport UCase(LstRptFile(lstReports.ListIndex)), acViewPreview
                    lintResult = ShowWindow(lAccess.hWndAccessApp, SW_SHOWNORMAL)
                'The report should just print
                Else
                    lAccess.DoCmd.OpenReport UCase(LstRptFile(lstReports.ListIndex)), acViewNormal
                   
                    lintResult = CloseHandle(lAccess.hWndAccessApp)
                    lAccess.CloseCurrentDatabase
                    Set lAccess = Nothing
                End If

I am using some api calls in this code to ensure that the report window is active once it is opened.

You can also check out my question:
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=visualbasic&qid=20300562

For me security of the database was an issue so I had to add some additional security in Access itself as well.
0
 
LVL 11

Expert Comment

by:arana
ID: 7011884
you can open access and have a report open in print preview mode with an access autorun macro, then call the report with printpreview

but this will work only with ONE report you choose

maybe if you try diferent access mdb with one report in each (yiack!!!)


0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:SiM99
ID: 7013223
carpediem,

aight, im trying your code out. (Didnt know you could access docmd, cool :)
but, err... what does the RptDest variable hold, and what vartype is it?
0
 
LVL 1

Author Comment

by:SiM99
ID: 7013229
also,
i'm assuming that lAccess was a Access.Application...
and what variable type was db?
0
 
LVL 1

Author Comment

by:SiM99
ID: 7013312
One more thing, how have you you made your user accounts?

Tried the security/user accounts menu option, but that makes them in the current system workspace, so they wouldn't be transferred with the database.

Have you used this method, or have you attatched the accounts to your database?
0
 
LVL 1

Accepted Solution

by:
carpediem earned 100 total points
ID: 7013550
Sorry for not commenting better.

RptDest is just an integer.  It is just a variable I set elsewhere to tell if the report should just print or if it should open in print preview.  If you are trying to open it in print preview you can get rid of that entire if statement and just use what is in the Else part.

Correct lAccess is Access.Application
and db is Object

As far as the security your right.  I had just done this yesterday myself and had only tested it locally.  I'm pretty new to Access security as in the past I have only used Access as a back-end database where I would set the database password and not worry about individual user rights.  I guess I'll have to look into this some more.
0
 
LVL 1

Expert Comment

by:carpediem
ID: 7014038
OK about the security.  If you do a search in Access help about security and Access workgroups you can read about all of this better than I will explain here, but here is what I'm planning to do.

When you define permissions with user accounts it creates a workgroup information file (usually where Access is installed) and Access uses that file for security locally.  However, using a utility called the WorkGroup Administrator you can put the file on in the network location as your database and then using WorkGroup Administrator on the client machines tell them to get their security information from the workgroup information file on the network, not thier own local copy.

I still don't like this a whole lot, but I'm going to try it initially and see how it works.
0
 
LVL 1

Author Comment

by:SiM99
ID: 7073038
Thanks.
I had also found the information about the workspaces, but it seems silly to try and get a client to install a workspace - in our situation anyway, we dont have all clients networked! :)

Got the reports to open at least...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Undo Button 1 32
Sharepoint list to Access database 9 44
MS Access Error Handling 6 28
MS Access VBA For Each Field Designation 3 18
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

740 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