Print only current record

Using Access 2007.

Hi all,
I'm trying to figure out how to show a report only displaying the current 
record. I created a db using the Issues Database as a template. It has a 
form called Issue Details which has a button that prints a report of all 
issues.
I created a new button and want to be able to print the same report but only 
with the record that is selected on the form.
I searched the 'net and based on what I found I added this to the button's 
Click event:
--------------------------------------
Private Sub Command188_Click()

On Error GoTo Err_Command188_Click

Dim MyForm As Form
Dim record_num As Long
Dim StrReportName As String


stDocName = "Issue Details"
StrReportName = "RA_BRL"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
record_num = MyForm.CurrentRecord
DoCmd.OpenReport StrReportName, acPreview, record_num, record_num


Exit_Command188_Click:
Exit Sub

Err_Command188_Click:
MsgBox Err.Description
Resume Exit_Command188_Click

End Sub
--------------------------------------

With the above code, I get an error that says that it cannot find the object 
'1'. Make sure that the object exists. I'm not sure what this could be since 
I haven't named anything as '1'.

Any suggestions on how I could achieve this?

Thanks. 

0
Jason
11/13/2007 2:37:07 PM
access.reports 4434 articles. 0 followers. Follow

2 Replies
1416 Views

Similar Articles

[PageSpeed] 49

Assuming IssueID is the numeric primary key of the table in the form and 
report, try:
  DoCmd.OpenReport StrReportName, acPreview, , "IssueID = " & record_num

-- 
Duane Hookom
Microsoft Access MVP


"Jason" wrote:

> Using Access 2007.
> 
> Hi all,
> I'm trying to figure out how to show a report only displaying the current 
> record. I created a db using the Issues Database as a template. It has a 
> form called Issue Details which has a button that prints a report of all 
> issues.
> I created a new button and want to be able to print the same report but only 
> with the record that is selected on the form.
> I searched the 'net and based on what I found I added this to the button's 
> Click event:
> --------------------------------------
> Private Sub Command188_Click()
> 
> On Error GoTo Err_Command188_Click
> 
> Dim MyForm As Form
> Dim record_num As Long
> Dim StrReportName As String
> 
> 
> stDocName = "Issue Details"
> StrReportName = "RA_BRL"
> Set MyForm = Screen.ActiveForm
> DoCmd.SelectObject acForm, stDocName, True
> record_num = MyForm.CurrentRecord
> DoCmd.OpenReport StrReportName, acPreview, record_num, record_num
> 
> 
> Exit_Command188_Click:
> Exit Sub
> 
> Err_Command188_Click:
> MsgBox Err.Description
> Resume Exit_Command188_Click
> 
> End Sub
> --------------------------------------
> 
> With the above code, I get an error that says that it cannot find the object 
> '1'. Make sure that the object exists. I'm not sure what this could be since 
> I haven't named anything as '1'.
> 
> Any suggestions on how I could achieve this?
> 
> Thanks. 
> 
0
Utf
11/13/2007 3:00:00 PM
Thanks, Duane. Works like a charm.
"Duane Hookom" <duanehookom@NO_SPAMhotmail.com> wrote in message 
news:DDE142DB-349F-43A2-A405-C70C8BC9E7D9@microsoft.com...
> Assuming IssueID is the numeric primary key of the table in the form and
> report, try:
>  DoCmd.OpenReport StrReportName, acPreview, , "IssueID = " & record_num
>
> -- 
> Duane Hookom
> Microsoft Access MVP
>
>
> "Jason" wrote:
>
>> Using Access 2007.
>>
>> Hi all,
>> I'm trying to figure out how to show a report only displaying the current
>> record. I created a db using the Issues Database as a template. It has a
>> form called Issue Details which has a button that prints a report of all
>> issues.
>> I created a new button and want to be able to print the same report but 
>> only
>> with the record that is selected on the form.
>> I searched the 'net and based on what I found I added this to the 
>> button's
>> Click event:
>> --------------------------------------
>> Private Sub Command188_Click()
>>
>> On Error GoTo Err_Command188_Click
>>
>> Dim MyForm As Form
>> Dim record_num As Long
>> Dim StrReportName As String
>>
>>
>> stDocName = "Issue Details"
>> StrReportName = "RA_BRL"
>> Set MyForm = Screen.ActiveForm
>> DoCmd.SelectObject acForm, stDocName, True
>> record_num = MyForm.CurrentRecord
>> DoCmd.OpenReport StrReportName, acPreview, record_num, record_num
>>
>>
>> Exit_Command188_Click:
>> Exit Sub
>>
>> Err_Command188_Click:
>> MsgBox Err.Description
>> Resume Exit_Command188_Click
>>
>> End Sub
>> --------------------------------------
>>
>> With the above code, I get an error that says that it cannot find the 
>> object
>> '1'. Make sure that the object exists. I'm not sure what this could be 
>> since
>> I haven't named anything as '1'.
>>
>> Any suggestions on how I could achieve this?
>>
>> Thanks.
>> 

0
Jason
11/13/2007 10:59:16 PM
Reply:

Similar Artilces:

Any ideas how I can Record Voice through Bluetooth onto Computer?
I am a Pilates teacher and would like to record some of my lessons as I deliver them. (I need to be free of wires). Apple can do it with Garage?? and a MAC but I don't have those. Any ideas? This is not an Office question. -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "Kirsty" <Kirsty@discussions.microsoft.com> wrote in message news:04CC1FF4-1436-4ED1-B83E-0D1CF2C42C9C@microsoft.com... >I am a Pilates teacher and would like to record some of my lessons as I > deliver them. (I need to ...

Print random invoices from multiple batches in one step
Hi, I am looking for a way to print random invoices (invoice #s separted by commas) in one step. Any help is greatly appreciated. Thanks If you are on v10, you can use the Sales Transactions List from the Navigation Bar (Click on Sales, then select All Sales Transactions) to pick specific invoice numbers. You may then click on the Print Documents option under the Actions toolbar on the ribbon to print those specific documents. Best regards, -- MG.- Mariano Gomez, MIS, MCP, PMP Maximum Global Business, LLC http://www.maximumglobalbusiness.com The Dynamics GP Blogster at...

how to print label on the very end of excel sheet
Hi, number of rows in my excel sheet varies. How can I solve following: I want label to be printed in the very end of sheet when printed (after the last row) Thanx alekm Kind of a "rows to repeat at bottom"??? Excel doesn't support this. Can you use the Footer? File|page setup|header/footer tab alekm wrote: > > Hi, > number of rows in my excel sheet varies. > How can I solve following: > I want label to be printed in the very end of sheet when printed (after the > last row) > > Thanx > alekm -- Dave Peterson Can I make specific footer that...

can't print to 11x17; publisher resizes to 8.5x11
Please see the thread http://groups.google.com/group/microsoft.public.publisher/browse_thread/thread/62ab7642d26291e6/6a7e4ba0f3ae6f3b?lnk=st&q=how+to+print+11+x+17&rnum=1&hl=en#6a7e4ba0f3ae6f3b To summarize, using Pub2003, windxp sp2, epson 1280, with ALL settings set to print at 11x17 (inc. the driver default setting), when the status monitor appears and the document begins printing, the status monitor says 8.5x11, and the document size is reduced to 8.5x11. I have the exact same problem, which AFAIK has never been resolved. I am sure it is NOT a printer driver issue, bec...

SOP Blank Invoice Form Not Printing Past Page 1
Hello: We have a Great Plains 7.5 client that is printing SOP invoices. Even though the invoices are somewhat lengthy and should be printing on page 1, 2, 3, 4, and so forth, the invoice only prints through page 1. What can we do in Report Writer to fix this? Or, is this a printer driver issue? If so, is there a 7.5 printer compatibility list that can be dug up from somewhere? Thanks! childofthe1980s ...

Designing Print Styles for Forms
I am using Outlook 2002, OS is Windows XP, and I have created a custom form. I need to create a print style that will allow me to define which fields and labels are printed and the location of the fields on the printed page. Any help will be greatly appreciated. Thanks. ...

My printer died. can a publisher 2003 doc be exported and printe.
I need to print a publisher 2003 document. I want to export it if possible and to take it to another printer/computer that does not have publisher on it and print it there. Is athis possible? Not unless you convert it into a .pdf file. Time for a new printer............. -- JoAnn Paules MVP Microsoft [Publisher] "Tonyg" <Tonyg@discussions.microsoft.com> wrote in message news:168EFC32-9395-4150-964C-08EFA6139FB6@microsoft.com... >I need to print a publisher 2003 document. I want to export it if possible > and to take it to another printer/computer that does not...

Enumerate ODBC System records
By calling CDatabase::OpenEx(NULL, CDatabase::forceODBCDialog) you get the ODBC DSN Control panel selection screen thingy to choose from. That screen has File, System and perhaps more tabs on them I want to not go through that selection window, instead only enumerate the System DSNs in my own app. I know this info is stored in the windows registry, but I'm looking to do this using the right way: documented API's. Any idea ? Lisa Take a look at the SQLDataSources API. This will allow you to enumerate the DSNs. HTH -- ============ Frank Hickman NobleSoft, Inc. ============ Replac...

Range of worksheets for printing.
How do I select and then deselect a range of worksheets for printing? Click the tab of the first worksheet, hold the Shift key down and click a second tab. All the worksheets between those two endpoints (inclusive) have been selected--and you can print them, print preview, etc. The selected sheet tabs will appear slightly whiter than the non- selected sheet tabs. If you want particular sheets, then CTRL + click on each of the sheet tabs. To unselect the sheets, click on a different sheet tab (not holding the Shift or CTRL key down). Or rightclick one of the sheet tabs within your s...

How to print a record in a form by pushing a button in another form ?
Hi ! I'm using MS Access 2003 and Windows XP Professional. I've a form A with a print button on it. Pushing its print button prints the form as it is displaying the current record. Now I 'd like to do the same thing by pushing a print button on another form B. E.g., pushing the button that is on B opens the form A, prints it as it is displaying the current record, and closes it again. How can this be done ? Your kind help will be greatly appreciated. Peter "pschrader" <none@none.de> wrote in message news:%23DLsP4XeIHA.5280@TK2MSFTNGP02.phx.gbl... >...

Word docs opening in Print Preview
I just upgraded to Office 2003, and now when I open a Word attachment in Outlook it immediately takes me to a Print Preview screen. Is this an Outlook setting I need to change, or a Word setting?? Thanks! --> Chris ...

How do i print out my spreadsheet with macro buttons?
Question above 1. create your macro using the macro recorder. 2. create your button using the Forms tool bar 3. assign the macro to the button. -- Enjoy the blessings of the day. jerry "Chris...." <Chris....@discussions.microsoft.com> wrote in message news:CC397D95-1F40-411E-B8C0-1A56AADD6DA3@microsoft.com... > Question above ...

Return multiple records from a single entry.
I have an access 2000 database which has records showing when activity takes place throughout the year. Each activity has a start date and an end date so forinstance the table could look like this. Event :- Major Race Specific :- Uk National Start Date :- 01/01/10 Wnd Date :- 31/01/10 Now I want to query if an event occurs on a particular week commencing (sunday) for instance 03/01/10. From my table I can see that the event started on 01/01/10 and finished 31/01/10 so would be applicable for week commencing 03/01/10. What I need to know is how to return this within a ...

How can I print 1 page in b/w & another in colour from a document?
I have a large number of documents that consist of some colour pages and some black and white pages. How can I set the document up in Word to recognise that when printing, colour pages print in colour and black and white pages print in black and white? I can only see that you choose colour or black and white to apply to the whole document when sending it to print. I have to then select colour but this means increased costs for printing my black and white sheets using colour ink. Please help!!!! Your monochrome pages should not be printed with color ink if you have a CMYK pr...

record cash receipt by invoice line item
Great Plains should allow the option to enter one cash receipt per invoice line item. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowser/en-us/default.mspx?mid=397cb5cd-706b-4edf-b717-1f0f64a1c01e&a...

calendar won't print
I have been using Word 2002 for several years to print monthly calendars. Suddenly it won't print the calendar and I can't see it in the print preview. The other various templates that I have tried seem to work okay. This is using the Calendar Wizard. The calendar comes up after creating it but when Print Preview is clicked it shows a blank screen and if printed, prints a blank page. -- Jerry emachine, T2798 Does no one have any ideas about this? -- Jerry emachine, T2798 "Gringo2" wrote: > I have been using Word 2002 for several years to pri...

Template for Excel to keep running record?
I need a template for Excel 2003 to keep a record of how much I run. Any tips? ...

Record Lock Problem
Hi All, I have a databse that runs queries against an ODBC source throughout the day and night. I am having an issue where a query will run at night and throw an error message about not being able to append due to record lock. What could be causing this? Is there a way to ignore the message? Any suggestions to avoid this? Thanks in advamce for the help! You could: Run the queries from code which traps the error Writes a message (including time error message etc) to a table Then resumes at the point following the error [On Error goto xxx :xxx Write error to errors table resume next ] ...

I can not get a text box to print.
The text box is with in the print area. I can not see it in print preview, and it does not print out. But I can see it when working the sheet 'Tooks' > 'Page Layout' > 'Sheet' tab' > DE-select 'Draft Quality'. Micky "Please help" wrote: > The text box is with in the print area. I can not see it in print preview, > and it does not print out. But I can see it when working the sheet Right-click on textbox and Format Text Box>Properties Enable "Print Object" Gord Dibben MS Excel MVP On Thu, 4 Fe...

printing business cards #14
H E L P ! What version Publisher? If you are using Publisher 2007 use one of the Avery US Letter templates. They work. Other versions of Publisher, page setup, business card. Almost all business cards are the same. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Laura_Lee42" <talktome@ihave problems.com> wrote in message news:5915A561-CD3B-45FF-BA1D-15EA4C0A4F38@microsoft.com... >H E L P ! ...

Printing embedded charts in Excel 2007
I'm not sure if this something peculiar to my system or Excel 2007. I'm finding that embedded charts are not printing correctly. They are larger than displayed on screen, even in page layout view, and they are not even close to where i place them on the page. In addition, they print as if they had been converted to images, with all the fuzziness that goes along with them. Am I doing something wrong, or is this just goofiness in beta? I just played around, and discovered in my case the chart is narrower in print than on screen (but then actresses have always known they look heavier...

Memo Printing
When printing a list of manes, etc in specific catagories the user name is bolded and underlined before each name and address. Is it possible to omit this information when printing and change it to a header only? Can this be turned off easily? -- mojhill ...

need clip art of bulding blue prints drawings can anyone help
need clip art for bussiness card back ground Try the Office clipart. A couple came up that may be suitable. http://office.microsoft.com/clipart/default.aspx?lc=en-us Input blueprint into the search. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "pelone" <pelone@discussions.microsoft.com> wrote in message news:B672EF98-E691-44A1-9085-821F760B2A61@microsoft.com... > need clip art for bussiness card back ground ...

MS PUB 97 crashes on "print" command (XP Home Ed)
How can I prevent MS Publisher 97 from crashing when commanded to print a document? The file will print, but then MS Pub closes. I'm running XP Home Edition, w/ Service pack 1. TIA TonyT Microsoft Office Publisher 2003 and older are critical about printer drivers. Usually upgrading (or downgrading in some cases) will fix the problems you are encountering. If you have not already done so, you would want to visit the manufacturers website of your printer to download and install the latest printer driver that is available. It's important to note that the CD-Rom that came with your...

How do I print odd numbered pages
I want to print double sided. The even numbers on one side and the odds on the other. Is there a way to do this in Excel Maryjanet, check your printer settings there may be an option there to do it, if not here is a macro from Gord Dibben that will do it Sub PrintDoubleSided() 'Will print odd or even pages 'By Gord Dibben Dim Totalpages As Long Dim pg As Long Dim oddoreven As Integer On Error GoTo enditt Totalpages = ExecuteExcel4Macro("Get.Document(50)") oddoreven = InputBox("Enter 1 for Odd, 2 for Even") For pg = oddoreven To Totalpages Step 2 ActiveWindow.S...