473,395 Members | 1,637 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,395 software developers and data experts.

Printing a detail of a single record (ie report)

I am new to MS Access so please bear with me. I am trying to create a
report format and attach a button to a form. This would users to
print-out a record that they are looking at. I can report a report
which print out the entire database so how do I limit it do just the
record that the user see on screen?

Thanks for the tip.

Jan 13 '06 #1
10 4578
Fendi:

In the VB code for your form button, find the line that opens your
report, and change it like this (all one line):

DoCmd.OpenReport stDocName, acPreview,,"Put Your Criteria Here ="
& Me!FieldName

Replace the "Put Your Criteria Here" with the criteria for your report
to limit the records returned, such as "[RecordID] = " Me!RecordID.
The Criteria portion is basically a where clause without the word
WHERE.

HTH,
Jana

Jan 13 '06 #2

Jana wrote:
Fendi:

In the VB code for your form button, find the line that opens your
report, and change it like this (all one line):

DoCmd.OpenReport stDocName, acPreview,,"Put Your Criteria Here ="
& Me!FieldName

Replace the "Put Your Criteria Here" with the criteria for your report
to limit the records returned, such as "[RecordID] = " Me!RecordID.
The Criteria portion is basically a where clause without the word
WHERE.

HTH,
Jana


Thank you Jana. I'll give it a go.

Jan 14 '06 #3
Jana

I tried this and somehow I am not getting the right result.

Dim stDocName As String
stDocName = "dbo_School Query"
DoCmd.OpenReport stDocName, acPreview, , [SchoolID] = Me!SchoolID,
acDialog

I tried diffent combination of schoolID and even hard coding the
Me!SchoolID but the result is still the same, the report generates for
all the schools in my database.

Do I need to do anything to the report format itself?

Regards

Jan 15 '06 #4
Fendi Baba wrote:
Jana

I tried this and somehow I am not getting the right result.

Dim stDocName As String
stDocName = "dbo_School Query"
DoCmd.OpenReport stDocName, acPreview, , [SchoolID] = Me!SchoolID,
acDialog

I tried diffent combination of schoolID and even hard coding the
Me!SchoolID but the result is still the same, the report generates for
all the schools in my database.

Do I need to do anything to the report format itself?

Regards

Surround this text: [SchoolID] = Me!SchoolID
by quotes like:

DoCmd.OpenReport stDocName, acPreview, , "[SchoolID] = Me!SchoolID",
acDialog
Jan 15 '06 #5
Bob

Thanks that worked. However, can I asked what does Me!SchoolID do? It
doesn't seem to pick up the schoolid field on the form but instead
requires me to enter a value is a prompt box.

Regards

Jan 15 '06 #6
Resolved. I found the code. I changed this portion to
"[SchoolID]=forms!frmSchoolData.SchoolID"

Jan 15 '06 #7
I think it shoud be:
"SchoolID = " & me!SchoolID. (better than
"[SchoolID]=forms!frmSchoolData.SchoolID" - if for instance you change
the name of the form the report may stop working).

so assuming SchoolId is 147 on the form this will be passed as a
WhereCondition to the report as "SchoolId = 147", i.e. the value of
SchoolId is resolved before the WhereCondition is passed - so it gets
passed as a literal.

You are passing to the report "SchoolId = forms!frmSchoolData.SchoolId"
which also works because the report resolves forms!SchoolData.SchoolId
by looking into the named form for field SchoolId.

If you pass "SchoolId = me!schoolID" (all in quotes) then in the report
- 'Me' is no longer the form but the report (i.e. the current object)
and the fact that it gives a popup box means it cant find a field
SchoolId to get the value from.

You also need Filter On set to yes in the report for it to work.

Jan 17 '06 #8
Thanks, I appreciate the fact you explained how Me!SchoolID worked. So
basically i hv to put it outside the quotes. I'll give it a go.

Regards.

Jan 17 '06 #9
Fendi:

Sorry for the delay in checking this thread...haven't been online in a
while.

Here's the proper way to have your line of code (all one line):
DoCmd.OpenReport stDocName, acPreview, , "[SchoolID] = " & Me!SchoolID

The & causes a concatenation of the [SchoolID] = and your SchoolID on
the form. The , acDialog should not be there, as that particular
parameter only applies to the DoCmd.OpenForm method. Report viewing
options are specified where you have the VB constant acPreview.

HTH,
Jana

Jan 17 '06 #10
Thanks, everyone. The input really helps.

Jan 19 '06 #11

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

Similar topics

1
by: Stewart Graefner | last post by:
I have been unable to locate anywhere the answer to my problem. I would like to be able to download/import a single record. This record is stored in many different related (one to one) tables. I...
2
by: Ray | last post by:
Dear all, I would like to ask if the crystal Report can remove if blank in Detail just like Report in Foxpro? Thanks a lot, Ray
0
by: Andy | last post by:
Hi All. I'm working for a company that has set out a guideline for retrieving data from a database. Nobody can explain to me the reason for the following. When retrieving a set of records...
6
by: ApexData | last post by:
When I use Dlookup. I am only able to return a single value and therefore cannot seem to assign a single records (3-field values) to (3-Variables). I noticed that I can get the 3-field values, but...
2
by: aro818 | last post by:
Hi I am creating a microsoft database and am currently stuck. I need to print one record at a time when in form view. to do so, I need to create a script which uses a value in the table which is a...
6
by: jweaver | last post by:
I have set up an event to print a single record report in access with the criteria below, however each time I enter a claim ID to preview a report, I am able to see the correct claim ID but the...
0
by: AmateurDBer | last post by:
Hello, I'm looking for Allen. I hate to bother you again, but I am now trying to e-mail the single record from the same form mentioned before (using a macro button) (reference thread about...
1
by: Steve Eccles | last post by:
I'm trying to print out only the current record from my form in a report but each time all the records print out. How can I print only one record using a report. I have place a button in the...
2
by: Greg (codepug | last post by:
acCmdPrint allows me to print using the Windows Dialog. Since I want to be able to select the printer of my choice, this works well. I put his behind a button on a single form. The problem is,...
2
by: simulationguy | last post by:
I have a report that prints all of the records out from a table, usually executed from a reports menu. The user also wants a print button on the data entry form that will print out the exact same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.