Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preview a report

Status
Not open for further replies.

robinsql

Programmer
Aug 2, 2002
236
IE
Hi,

I am trying to preview an Access report from within my VB application.
Can somebody please tell me why the following code does not work?

strDBDir = g_Conn.Properties("Data Source")
Set objAccess = CreateObject("Access.Application")
objAccess.OpenCurrentDatabase strDBDir, False
objAccess.DoCmd.OpenReport "rptName", acViewDesign
objAccess.Reports(0).RecordSource = sSQL
objAccess.DoCmd.OpenReport "rptName", acViewPreview
objAccess.DoCmd.OpenReport "rptName", acViewNormal
objAccess.CloseCurrentDatabase
objAccess.Quit acQuitSaveNone


Any help gratefully received.
Thanks,
Robin
 
Hi,
Do you have a line like this that declares objAccess?
Dim objAccess as Object
Additionally, I don't understand why you are creating another instance of Access if the report already exists inside your current database. Am I missing something here?

HTH, [pc2]
Randy Smith, MCP
California Teachers Association
 
Hi,
I just used the following and it worked...

objAccess.Visible = True

The only problem is that this shows the entire DB. Is it possible to just show the report as I don't want the user to edit the DB like this?

Thanks,
Robin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top