Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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
 
Old June 25th, 2003, 10:32 AM
Registered User
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Changing print options within Access VBA

I want to print a selected record using a Print button on a Form.

Currently we use the Form to view record contents. When we have the record we wish to print we have to use File | Print then click the Selected Record radio button then OK.

Do any of you know how we can select the current record through code rather than the print dialog.

Cheers,


Michael T. Ross
Software Design Assurance
[email protected]
 
Old June 25th, 2003, 08:52 PM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I would start by investigating the "RunCommand" action of the Application object. It replaces the earlier AccessBasic "DoMenuItem".



John Pittaway
Our's is an ego-busting profession.
 
Old June 27th, 2003, 12:06 PM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is quite simple. First, you create a report with the appropriate layout. Don't fill in the property of Data/Record Source. You'll specify it in code.
Second, the underlying code of the Print Button command on your form contains code like this:

   Dim strSQL as String
   strSQL = "SELECT fields FROM table WHERE radioButton = -1"
   ...
   report.RecordSource = strSQL
   ... open the report ...

Principally, this means that you set the RecordSource property of the report in code. When the report is to be opened, it's RecordSource property is set dynamically in runtime.
The report will show only those records you selected in the form.
If you're a bit handy in VBA, you can manipulate a lot in runtime via code.
I hope this gets you on your way.

Cheers,

Phil Sieben
_______________________________

Quote:
quote:Originally posted by rossmic
 I want to print a selected record using a Print button on a Form.

Currently we use the Form to view record contents. When we have the record we wish to print we have to use File | Print then click the Selected Record radio button then OK.

Do any of you know how we can select the current record through code rather than the print dialog.

Cheers,


Michael T. Ross
Software Design Assurance
[email protected]





Similar Threads
Thread Thread Starter Forum Replies Last Post
Print Query in Landscape using VBA RPetto85 Access VBA 2 June 19th, 2007 04:25 AM
Access to tools>Options DarrenMelling Pro VB 6 1 November 30th, 2006 10:28 AM
access forms & mouse options killroy Access 1 September 13th, 2005 12:56 AM
Changing Cell-formating in Excel via VBA Gert VB How-To 4 May 10th, 2005 01:56 PM
Changing print drivers JLS VBScript 0 October 14th, 2003 04:59 PM





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