Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 22nd, 2004, 06:06 PM
Authorized User
 
Join Date: Aug 2004
Location: Harrisburg, PA, USA.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default Private Function DisplayReport()

I have the following code in the click event for my Display Report command button:

Private Sub cmdDisplayReport_Click()

    'Open the selected report in Datasheet view.
    DoCmd.OpenReport [lboxReportList]

End Sub

Something strange happens when I click the command button and I don't know why. When I click the button it first prints out the report then opens it. The only thing with this report is that it has a parameter query data source(all of my reports do), but I can't see that being the problem. Any suggestions? Thank you all.

Reply With Quote
  #2 (permalink)  
Old October 22nd, 2004, 06:37 PM
Authorized User
 
Join Date: Oct 2004
Location: Austin, TX, USA.
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You should do:

DoCmd.OpenReport Me.lboxReportList, acViewPreview

.. to ensure the report opens in print preview. If you don't add the second parameter, the report should go directly to the printer.

John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
Reply With Quote
  #3 (permalink)  
Old October 25th, 2004, 04:26 PM
Authorized User
 
Join Date: Aug 2004
Location: Harrisburg, PA, USA.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank You,
That worked. I do have one question though. I did some experimenting with the VBA Code that you included. When I put Me.lboxReportList in brackets it gives me an error. But when I remove the brackets the code works. Can you explain why it does this just(for my common knowledge)?

Reply With Quote
  #4 (permalink)  
Old October 25th, 2004, 04:48 PM
Authorized User
 
Join Date: Oct 2004
Location: Austin, TX, USA.
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In general, you need brackets only around a name that contains spaces, special characters, or that is the same as a reserved word (such as Date or Name). However, it never hurts to put brackets around a name. You never put brackets around an object reference -- and "Me" is a shorthand object reference to the form in which this code is running. So, the following are OK:

  Me.lboxReportList
  Me.[lboxReportList]
  Me![lboxReportList]

The following are not ok:

  [Me].lboxReportList
  [Me].[lboxReportList]
  [Me.lboxReportList]



John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help!!!!!Private Sub Worksheet_Change VicM Excel VBA 1 March 6th, 2008 10:35 PM
Private Messages ViagraFalls BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 10 October 22nd, 2007 03:48 PM
private constructor in C# n.nsivakumar C# 1 August 16th, 2006 07:08 AM
address of private pages hamidreza_buddy Beginning PHP 1 May 9th, 2005 09:41 PM
Using Private Sub cutovoi Excel VBA 0 February 5th, 2004 12:55 PM



All times are GMT -4. The time now is 09:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.