Thanks to all for the VBA book suggestions. Dave ________________________________
From: [email protected] on behalf of Dick Root Sent: Sun 8/19/2007 11:01 AM To: [email protected] Subject: [ms_access] Re: Print report Dave, There a many good VBA books: Mastering VBA (Mastering) by Guy Hart-Davis VB and VBA in a Nutshell: The Languages by Paul Lomax my favorite - VBA Developer's Handbook, 2nd Edition by Ken Getz and Mike Gilbert Absolute Beginner's Guide to VBA (Absolute Beginner's Guide) by Paul McFedries VBA for Dummies by John Paul Mueller Dick --- In [email protected] <mailto:ms_access%40yahoogroups.com> , "Dave Moreau" <[EMAIL PROTECTED]> wrote: > > John: > I am ready to really dive into using VBA coding to improve my access > skills. What are your recommendations for doing so? I have not seen a > local class that is strictly designed to address VBA coing in Access. > Is there such a book that gets into the details of customizing many > reporting functions of Access. I already have the basic books but a > class might be better so that when questions arise from reading and > experimenting, I can ask an instructor....perhaps an online course you > may be familiar with? > Dave Moreau > > ________________________________ > > From: [email protected] <mailto:ms_access%40yahoogroups.com> > [mailto:[email protected] <mailto:ms_access%40yahoogroups.com> ] On > Behalf Of John Viescas > Sent: Saturday, August 18, 2007 7:14 AM > To: [email protected] <mailto:ms_access%40yahoogroups.com> > Subject: RE: [ms_access] Re: Print report > > > > Try this: > > Private Sub cmdReport_Click() > On Error GoTo Err_cmdReport_Click > > Dim stDocName As String > Dim stFilter As String > > stDocName = "Firefighter Report" > stFilter = "[nims#] = " & Me![nims#] > DoCmd.OpenReport stDocName, acPreview, _ > WhereCondition:=stFilter > > Exit_cmdReport_Click: > Exit Sub > > Err_cmdReport_Click: > MsgBox Err.Description > Resume Exit_cmdReport_Click > > End Sub > > For this to work, the Primary Key field must be in the Record Source of > both > the form and the report. The syntax is a little funky because you're > using > a reserved character (#) in the field name. > > John Viescas, author > Microsoft Office Access 2007 Inside Out > Building Microsoft Access Applications > Microsoft Office Access 2003 Inside Out > SQL Queries for Mere Mortals > http://www.viescas.com/ <http://www.viescas.com/> <http://www.viescas.com/ > <http://www.viescas.com/> > > (Paris, France) > For the inside scoop on Access 2007, see: > http://blogs.msdn.com/access/ <http://blogs.msdn.com/access/> > <http://blogs.msdn.com/access/ <http://blogs.msdn.com/access/> > > > -----Original Message----- > From: [email protected] <mailto:ms_access%40yahoogroups.com> > <mailto:ms_access%40yahoogroups.com> > [mailto:[email protected] <mailto:ms_access%40yahoogroups.com> > <mailto:ms_access%40yahoogroups.com> ] > On Behalf > Of volunteerff8 > Sent: Saturday, August 18, 2007 1:52 PM > To: [email protected] <mailto:ms_access%40yahoogroups.com> > <mailto:ms_access%40yahoogroups.com> > Subject: [ms_access] Re: Print report > > Okay I tried to follow your directions precisely what could still not > get it to print. Let me add little more information for you I am > working with access 2003. My form name is firefighters, my report > name is firefighter report. My primary key in my table is nims#. I > have tried copy and paste will your code and substituting my primary > key with the correct name. But still cannot get it to work. Could > you please let me know what I am doing wrong. I will keep checking > back for any updates thanks again. > > --- In [email protected] <mailto:ms_access%40yahoogroups.com> > <mailto:ms_access%40yahoogroups.com> , > "John Viescas" <JohnV@> wrote: > > > > Dear VolunteerFF: > > > > Open your form in Design view. Make sure the Control Wizards > button is > > clicked down in the Toolbox. Add a Command Button to your form, > and follow > > the steps to do Report Operations and select your report to open. > When > > you're done, make sure the new command button is selected, scroll > down in > > the Properties window until you find the On Click property (it > should say > > [Event Procedure]), click in the property, and then click the Build > buttton > > (...) that appears next to the property. You should see the Visual > Basic > > editor open with code like this: > > > > Private Sub cmdReport_Click() > > On Error GoTo Err_cmdReport_Click > > > > Dim stDocName As String > > > > stDocName = "Firefighter Report" > > DoCmd.OpenReport stDocName, acPreview > > > > Exit_cmdReport_Click: > > Exit Sub > > > > Err_cmdReport_Click: > > MsgBox Err.Description > > Resume Exit_cmdReport_Click > > > > End Sub > > > > Note that I'm assuming the name of the report is "Firefighter > Report". > > You'll see something different if your report has another name and > you > > correctly picked it in the command button wizard. > > > > I'm going to assume that your name and address table has a Primary > Key field > > called ID - simply a unique sequence number that identifies each > unique > > record. Under that assumption, change the code to: > > > > Private Sub cmdReport_Click() > > On Error GoTo Err_cmdReport_Click > > > > Dim stDocName As String > > Dim stFilter As String > > > > stDocName = "Firefighter Report" > > stFilter = "ID = " & Me.ID > > DoCmd.OpenReport stDocName, acPreview, _ > > WhereCondition:=stFilter > > > > Exit_cmdReport_Click: > > Exit Sub > > > > Err_cmdReport_Click: > > MsgBox Err.Description > > Resume Exit_cmdReport_Click > > > > End Sub > > > > The first version of the code is doing what your macro is probably > doing - > > opening the entire report in Print Preview. The second version > adds a > > filter to tell the report to print only the record for the current > fire > > fighter. > > > > Write again if you can't get that to work or some other field is > the Primary > > Key of your table. > > > > John Viescas, author > > Microsoft Office Access 2007 Inside Out > > Building Microsoft Access Applications > > Microsoft Office Access 2003 Inside Out > > SQL Queries for Mere Mortals > > http://www.viescas.com/ <http://www.viescas.com/> <http://www.viescas.com/ > > <http://www.viescas.com/> > > > (Paris, France) > > For the inside scoop on Access 2007, see: > > http://blogs.msdn.com/access/ <http://blogs.msdn.com/access/> > > <http://blogs.msdn.com/access/ <http://blogs.msdn.com/access/> > > > > > > > > > -----Original Message----- > > From: [email protected] <mailto:ms_access%40yahoogroups.com> > > <mailto:ms_access%40yahoogroups.com> > [mailto:[email protected] <mailto:ms_access%40yahoogroups.com> > <mailto:ms_access%40yahoogroups.com> ] > > On Behalf > > Of volunteerff8 > > Sent: Saturday, August 18, 2007 12:44 AM > > To: [email protected] <mailto:ms_access%40yahoogroups.com> > > <mailto:ms_access%40yahoogroups.com> > > Subject: [ms_access] Print report > > > > Hello everyone I new it this I'm trying to make a very simple > > database. I created a database to keep track of them members of my > > fire station. It's very simple just keeps track of their address > phone > > numbers emergency contacts and so forth. Then I created a form to > make > > it easy to input the information. Then I created a report to print > the > > information in a more printer friendly format. The problem that I > am > > having is that I added a cracked button on my form. When I press > this > > button it wants to print my whole database file. But what I would > like > > to do is just print the file that I am looking at not the whole > > database. Could someone tell me what I'm doing wrong. I created a > > micro that first opened in the report and then tells it to print > it. > > How do I go about telling it to just print the file that I am > looking > > at. Again I am just a novice at this and by no means any > programmer. > > If somebody could send me the code that I could copy and paste and > put > > in the proper name of my reports and database I would greatly > > appreciate it. I can be reached at dberryc8@ thanks for your > > help. > > > > > > > > > > Yahoo! Groups Links > > > > Yahoo! Groups Links > > > > > > This e-mail and any attachments may be confidential or legally privileged. > > > > [Non-text portions of this message have been removed] > This e-mail and any attachments may be confidential or legally privileged. [Non-text portions of this message have been removed]
