Solved

Preview a report from data in a form - Access 2003

Posted on 2006-06-13
5
239 Views
Last Modified: 2008-03-17
I am having trouble getting a report to preview/print correctly.  Since I haven't done Access programming in over a decade, I'm afraid my skills have slipped.  Here is what I have:  A combo box on a form selects an import date from a list, and then the form only displays the records that match the import date.  The Row Source property of the combo box is set as follows:  

SELECT tblPermitData.ImportDate FROM tblPermitData GROUP BY tblPermitData.ImportDate ORDER BY tblPermitData.ImportDate

After the date is selected, the user presses a button labeled 'Refresh', which has the On Click event set to:
Me.Requery

This all works fine and dandy.

So I put a button on the form for Print Preview, and created a report with the fields I want included.  But I can't figure out how to select only the data that is diplayed in the form.  Thanks in advance for any help.

Lew
0
Comment
Question by:lewhuskey
  • 4
5 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 16898036
Hi Lewhuskey,

If your data has a primary key uniquely identifying each record (I'll refer to it as ID), you can add a textbox to your form abd bind it to that ID field and call it txtID(you can set the textbox's visible property to "no" if you don't want it displayed).  

In the button that opens your report, use the following OpenReport statement:

Docmd.OpenReport "rptYourReportName", acViewPreview,, "ID = " & me.txtID
0
 
LVL 61

Expert Comment

by:mbizup
ID: 16898053
You would also need to include the ID in your select statement for the report's recordsource:

SELECT ID, tblPermitData.ImportDate FROM tblPermitData GROUP BY tblPermitData.ImportDate ORDER BY tblPermitData.ImportDate
             ^--- Add ID here

0
 
LVL 61

Accepted Solution

by:
mbizup earned 125 total points
ID: 16898071
Sorry... I misread a good portion of the question.  If you only want the report to display records based on the date... then change the openreport statement as follows:

Docmd.OpenReport "rptYourReportName", acViewPreview,, "ImportDate = #" & Me.txtImportDate & "#"

(and ignore my previous posts completely)
0
 

Author Comment

by:lewhuskey
ID: 16935600
Thanks, mbizup, that did it.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 16936740
Glad to help!
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question