473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

MS Access Forms and Reports Question

Hey folks,

I am trying to make a form that has a button linked to a report. Instead of
when pressing the button just bringing up the specific records information,
it is searching the whole table that the form is linked to and bringing that
up in the report.

I know there is a way to just print the selected record in the form and turn
that into a report and print that. Does anyone know how to do this? Does a
query need to be made? I tried searching the help files to no avail. I
have done this before a long time ago, I just don't remember how.

Thanks

Allison

Sep 24 '06 #1
2 1205
Allison wrote:
Hey folks,

I am trying to make a form that has a button linked to a report.
Instead of when pressing the button just bringing up the specific
records information, it is searching the whole table that the form is
linked to and bringing that up in the report.

I know there is a way to just print the selected record in the form
and turn that into a report and print that. Does anyone know how to
do this? Does a query need to be made? I tried searching the help
files to no avail. I have done this before a long time ago, I just
don't remember how.
Thanks

Allison
It is very common in Access to need to...

Open a Form pre-filtered based on the value of one or more controls on the
current form.

Open a Report pre-filtered based on the value of one or more controls on the
current form.

Even though these are both about as common, the New Command Button wizard only
provides a method to build for you a button that does this for Forms. Why they
don't provide a wizard to do this for reports has always baffled me.

The resulting syntax is almost exactly the same. If you look at the code in the
Click event of your existing button that opens your report you will see that it
uses the OpenReport method of the DoCmd object. That method has an optional
WHERE argument that can be used to apply a filter to the report being opened.
All you have to do is populate that argument including references to controls on
your form. Here is a simple example where the form and report both have a
common single numeric field [ID] to be used for the filter.

DoCmd.OpenReport "ReportName", acViewPreview, , "ID = " & Me!ID
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Sep 24 '06 #2
On Sun, 24 Sep 2006 15:44:49 +1000, Allison wrote:
Hey folks,

I am trying to make a form that has a button linked to a report. Instead of
when pressing the button just bringing up the specific records information,
it is searching the whole table that the form is linked to and bringing that
up in the report.

I know there is a way to just print the selected record in the form and turn
that into a report and print that. Does anyone know how to do this? Does a
query need to be made? I tried searching the help files to no avail. I
have done this before a long time ago, I just don't remember how.

Thanks

Allison
Your table should have a unique prime key field.
In my example it is named [RecordID].

On the Form's command button's property sheet write
[Event Procedure]
on the Click event line.
Then click on the little button with 3 dots that will appear on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines write:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If, however, [RecordID] is Text Datatype, then use:

DoCmd.OpenReport "ReportName", acViewPreview, ,"[RecordID] = '" &
[RecordID] & "'"

as the Where clause.

For clarity, the single and double quotes are..
"[RecordID] = ' " & [RecordID] & " ' "
Change [RecordID] to whatever the actual field name is that you are
using.

See VBA Help files for:
Where Clause + Restrict data to a subset of records'
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Sep 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: ronwer | last post by:
Hello, The title doesn't completely cover the question I have, but it's a bit more complicated problem we have. We are using a database, based on Acces, but developed by a third party...
6
by: Serious_Practitioner | last post by:
Good day all, and thank you in advance for your help. No - MANY thanks in advance for your help - I know nothing about using databases on Web servers. I am about to discuss a project with a...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
18
by: Andre Laplume via AccessMonster.com | last post by:
I have inherited a bunch of dbs which are are shared among a small group in my dept. We typically use the dbs to write queries to extract data, usually dumping it into Excel. Most dbs originated...
3
by: Jerome | last post by:
Hi there, I've got an MS Access application with multiple tables, queries, forms (and sub-forms!), reports ... It would be neat if that application could be migrated to ASP.NET since it...
7
by: WC Lo | last post by:
I am using VBA with MS Access. Is it possible to using VB.Net on Access? Any useful links explaining this?
6
by: Bob Alston | last post by:
I am looking for Access reporting add-in that would be easy to use by end users. My key focus is on selection criteria. I am very happy with the Access report writer capabilities. As far as...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
5
by: Anns via AccessMonster.com | last post by:
My establishment has about 20 ms access db's that will be converted over (see subject). When we pull all the BE's over to SQL and the FE's on Sharepoint (.net) surely we don't have to change...
6
by: DeniseY | last post by:
I have an Access report that is created on the fly by the user selecting the fields to be included. The Access report comes out fine, but I want it to automatically output to an Excel spreadsheet....
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.