PDA

Click to See Complete Forum and Search --> : Don't want Access window.


Rob Brown
Oct 30th, 2000, 08:53 AM
Hi,

I'm using the following code in VB5 to open an Access 97 report(acPreview).

I'm then immediately using the OutputTo method from Access to create an HTML page from the report.

Does anyone know how I can stop Access opening in it's own window?

'Declare the variable
Dim appAccess As Access.Application

'Create a new access application
Set appAccess = New Access.Application

'Open the database
appAccess.OpenCurrentDatabase _
"G:\Wiz Add Ins\Energy Client\Database\Energy Client.mdb"

'Open the report
appAccess.DoCmd.OpenReport "rptStatement", _ acViewPreview, , "[Date] = #" & datReportDate & "#"

'Output the statement report to an HTML file
appAccess.DoCmd.OutputTo acOutputReport, "rptStatement", _ acFormatHTML, _
"G:\Wiz Add Ins\Energy Client\HTM\Statement.Htm"

'Close access
appAccess.Quit

Any suggestions would be greatly appreciated,

Best regards,

Rob Brown.

paulw
Oct 30th, 2000, 09:35 AM
Rob,

Try turning screen painting off before opening the access app and then setting the Application.Visible property to false, then repaint the screen.


Me.AutoRedraw = False
appAccess.Visible = False
Me.AutoRedraw = True


BTW Why are you previewing the report? There is no 'get-out' to cancel the file creation - you can just do that in one step.

Cheers,

Paul

[Edited by paulw on 10-30-2000 at 10:49 AM]

Rob Brown
Oct 30th, 2000, 10:11 AM
Hi Paul,

I tried the code before opening the new Access app. I get an 'Object or with block variable not set' run time error.

If I insert it after this it hides my window but leaves the Access button in the task bar, I hate to be a pain but I don't want this either on the pretext of 'If it's there it will be clicked on'. This application is an add-in for a SCADA system and some of my users are not exactly what you'd call computer literate (they have been known to phone for tech-support when the screen saver has come on).

I have to preview the report because I need to get the criteria string in, the report is a statement detailing electricity usage and costs and in this instance has to show records from only the current day.

Any more ideas would be greatly appreciated.

Best regards,

Rob Brown.

paulw
Oct 30th, 2000, 10:26 AM
Hi Rob,

Yeh, I thought the task bar might be a problem. I do not think that you can stop the window coming up programatically. Have you tried playing around with the start up options?

the only other alternative I can think of is something like Crystal Reports.

Cheers,

Paul

Coder Guy
Oct 31st, 2000, 03:49 PM
If you've looked through the Microsoft knowledge base,
checked the MSDN site, and alot of resources on the web for your answer and still can't find a way to do it...

Your only solution might be API calls to remove the visibility of the objects all together. If done properly, you could do it without it causing any problems.

It might be tricky, but if your real desperate you
can pick up a book on using the Windows API in VB (Daniel Appleman makes a good one)...

Hope this helps...

PS: I've done similar things with the API before
and it's not that difficult once you figure
out which combination of API calls you need to use...

Rob Brown
Nov 1st, 2000, 02:53 AM
I've had to do this using the ShowWindow API as follows:

intRetVal = HideWindow(AppAccess.hWndAccessApp, 0)

This works OK but the window still appears in the taskbar briefly after the New Access.Application statement.

Oh well, it'll just have to do I suppose.

Best regards,

Rob Brown.