SiM99
asked on
Access reports in VB
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
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
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, ...)
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.Appli cation")
Set db = lAccess.Application.DBEngi ne.Workspa ces(0).Ope nDatabase( IPDBNAME, 0, False, ";pwd=X1JFH9")
lAccess.Visible = False
lAccess.OpenCurrentDatabas e IPDBNAME, False
Set db = Nothing
lintResult = SetForegroundWindow(lAcces s.hWndAcce ssApp)
'The report should open in printpreview
If RptDest = 0 Then
lAccess.DoCmd.OpenReport UCase(LstRptFile(lstReport s.ListInde x)), acViewPreview
lintResult = ShowWindow(lAccess.hWndAcc essApp, SW_SHOWNORMAL)
'The report should just print
Else
lAccess.DoCmd.OpenReport UCase(LstRptFile(lstReport s.ListInde x)), acViewNormal
lintResult = CloseHandle(lAccess.hWndAc cessApp)
lAccess.CloseCurrentDataba se
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:
https://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.
Here is the code I am using until I can find something better.
Set lAccess = CreateObject("Access.Appli
Set db = lAccess.Application.DBEngi
lAccess.Visible = False
lAccess.OpenCurrentDatabas
Set db = Nothing
lintResult = SetForegroundWindow(lAcces
'The report should open in printpreview
If RptDest = 0 Then
lAccess.DoCmd.OpenReport UCase(LstRptFile(lstReport
lintResult = ShowWindow(lAccess.hWndAcc
'The report should just print
Else
lAccess.DoCmd.OpenReport UCase(LstRptFile(lstReport
lintResult = CloseHandle(lAccess.hWndAc
lAccess.CloseCurrentDataba
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:
https://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.
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!!!)
but this will work only with ONE report you choose
maybe if you try diferent access mdb with one report in each (yiack!!!)
ASKER
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?
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?
ASKER
also,
i'm assuming that lAccess was a Access.Application...
and what variable type was db?
i'm assuming that lAccess was a Access.Application...
and what variable type was db?
ASKER
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
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...
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...