By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,693 Members | 1,799 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,693 IT Pros & Developers. It's quick & easy.

How do I do a print preview using Access Automation in VB? Print works fine.

P: n/a
This opens the report and prints it out:

objAccess.DoCmd.OpenReport ("Invoice")

But I can't seem to use any options.

How can I print preview? I get a syntax error when I use the
acViewPreview option.

Is there a good site where I can learn about Automation?

Is this the right group for these questions? If not, please tell me
what group is.

Thanks.
Greg Teets
Cincinnati Ohio USA
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Tue, 15 Feb 2005 22:38:40 GMT, Greg Teets wrote:
This opens the report and prints it out:

objAccess.DoCmd.OpenReport ("Invoice")

But I can't seem to use any options.

How can I print preview? I get a syntax error when I use the
acViewPreview option.

Is there a good site where I can learn about Automation?

Is this the right group for these questions? If not, please tell me
what group is.

Thanks.
Greg Teets
Cincinnati Ohio USA

3
Perhaps this will help.
Adapted from VBA help on the OpenCurrentDatabase method.

Option Compare Database
Option Explicit
Dim appAccess As Access.Application

Public Sub SetObjects()
' Initialize string to database path.
Const strConPathToSamples = "YourPath\YourFileName.mdb"
' Create new instance of Microsoft Access.
Set appAccess = CreateObject("Access.Application")
' Open database in Microsoft Access window.
appAccess.OpenCurrentDatabase strConPathToSamples
' Open a Report in Preview
appAccess.DoCmd.OpenReport "ReportName", acViewPreview
End Sub

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #2

P: n/a
On Tue, 15 Feb 2005 23:55:19 GMT, fredg <fg******@example.invalid>
wrote:
appAccess.DoCmd.OpenReport "ReportName", acViewPreview


This line causes a syntax error. If I leave off the second parameter
it prints out fine.

Thanks.
Greg Teets
Cincinnati Ohio USA
Nov 13 '05 #3

P: n/a
On Wed, 16 Feb 2005 00:11:41 GMT, Greg Teets wrote:
On Tue, 15 Feb 2005 23:55:19 GMT, fredg <fg******@example.invalid>
wrote:
appAccess.DoCmd.OpenReport "ReportName", acViewPreview


This line causes a syntax error. If I leave off the second parameter
it prints out fine.

Thanks.
Greg Teets
Cincinnati Ohio USA


Works fine for me.
Try using the acViewPreview constant's value instead.

appAccess.DoCmd.OpenReport "ReportName", 2

Does that 'fix' it?
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #4

P: n/a
On Wed, 16 Feb 2005 03:45:06 GMT, fredg <fg******@example.invalid>
wrote:
On Wed, 16 Feb 2005 00:11:41 GMT, Greg Teets wrote:
On Tue, 15 Feb 2005 23:55:19 GMT, fredg <fg******@example.invalid>
wrote:
appAccess.DoCmd.OpenReport "ReportName", acViewPreview


This line causes a syntax error. If I leave off the second parameter
it prints out fine.

Thanks.
Greg Teets
Cincinnati Ohio USA


Works fine for me.
Try using the acViewPreview constant's value instead.

appAccess.DoCmd.OpenReport "ReportName", 2

Does that 'fix' it?

That doesn't work either. Something's wrong here, I'm afraid.
Greg Teets
Cincinnati Ohio USA
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.