Solved

Preview a report from data in a form - Access 2003

Posted on 2006-06-13
5
237 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now