473,396 Members | 2,002 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,396 software developers and data experts.

How to Print Selected Record Only

I have an access db and when I ask it to print it insists on printing all of the records together instead of the one I have open. What am I doing wrong?
Sep 11 '11 #1
3 8426
NeoPa
32,556 Expert Mod 16PB
As the question is asked so inadequately I'm left guessing what you actually mean. That's the biggest mistake of course.

As for your database design though, I would guess you're trying to print a form instead of a report. That's possible of course, but it's not really what they were designed to do. They will print the current recordset, and not simply what's currently visible at the time of printing.

To handle printing the current record then design a report (or form actually, but a report is probably more sensible as that's what they were specifically designed to provide) to show the details you want and open it with a filter provided that includes only the record(s) that you want included in the printed report.
Sep 11 '11 #2
If your record id is a text field, you'll need to surround Me!MyRecordID with chr(34) like so

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm Me.Name, acPreview, , "MyRecordID = " & chr(34) & Me!MyRecordID & chr(34)
Where MyRecordID is the name of your unique record ID field.
Sep 14 '11 #3
NeoPa
32,556 Expert Mod 16PB
PDEBaets:
If your record id is a text field, you'll need to surround Me!MyRecordID with chr(34) like so
That's not actually quite true. That is one way of handling quotes in SQL but not a good way. Quotes should simply be used as is :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.OpenForm(Me.Name, acPreview, , "MyRecordID = '" & Me.MyRecordID & "'")
There is absolutely no need to confuse matters by using Chr(34), or even a more standards compliant version - Chr(39) (See Quotes (') and Double-Quotes (") - Where and When to use them).

Your point about needing quotes though (unfortunately masked rather than illustrated by the code example) is a good one and may prove helpful.
Sep 14 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: DD | last post by:
I have a mainForm with a subForm On the main form i have a combo with March 04, April 04 etc, you select a date and the subform shows all records for the selected date. I can print a selected...
0
by: Peter Rohlfs | last post by:
Is there a way to automate the printing of the group selected in the group tree only? I know they can enter a page range on the printer selection screen, but you need to know which pages to use...
2
by: dbuchanan | last post by:
Hello, I want to open a child form based on the record selected in a dataGridView of the parent form. I want the child form to open with a populated child table based on the selected parent...
5
by: Ren | last post by:
Hello all, I have a page which can list all records from a table in my local database. For each record that is displayed there is link next to it. When the link is pressed another page opens...
6
by: shulls | last post by:
I am trying to print the curent record that I have selected on the curent page in a form that I have created, with a subform on that same page. If I just do a "print" it will print only the first...
8
by: mci | last post by:
Hi! How can I print the selected record? I'm using visual basic 6. After I search the record, it display in the form but when I click the print button all the records will print. What I want is...
8
by: wassimdaccache | last post by:
Hello everybody The name of the form that I'm working on is 'AddProduct' I'm trying to print a selected record that I have the focus, its name is "barecode" My report name is ...
2
by: eneyardi | last post by:
How to filter selected record in a report? i have a form name Data Tracking Details where i can view my records one by one using record selector. Now, i want my current record in a form to be...
2
by: Giggly | last post by:
I have an access database and I have a macro in it that has the folowing commands: GotoRecord - Next OpenReport - Report Name: Single Receipt - View: Print I want the OpenReport to print...
2
by: David Patz | last post by:
Is it possible for a user to select a record from a datasheet in a subform, double click it, and write that specific record to another table? I have attempted to perform this task using...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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.