Having problems printing a single report

Hi 

This is the code I have entered in the event procedure to print a single 
record.

Unfortunately, it's not working. How do I fix this code:

Private Sub Print_this_record_Click()

Dim strDocName As String
Dim strWhere As String
    strDocName = "R1-1 GPS_GeneralInfo"
    strWhere = "[StudentID]=" & Me!StudentID
    DoCmd.OpenReport strDocName, acPreview, , strWhere
    
End Sub


I need to print out one StudentID for the report R1-1 GPS_GeneralInfo.  When 
I click on the button, a popup box with the Student CG2002 appears.

Thanks for your help in advance.
0
Utf
4/10/2010 12:54:01 AM
access.reports 4434 articles. 0 followers. Follow

3 Replies
831 Views

Similar Articles

[PageSpeed] 36

It seems your student code field is a text field, not a number field. You 
will therefore need to add quotes:
    strWhere = "[StudentID]=""" & Me!StudentID & """"

For an explanation of the quotes, see:
    Quotation marks within quotes
at:
    http://allenbrowne.com/casu-17.html

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"forest8" <forest8@discussions.microsoft.com> wrote in message 
news:A5AD81BD-2356-4B60-B6DD-D0B71088563B@microsoft.com...
> Hi
>
> This is the code I have entered in the event procedure to print a single
> record.
>
> Unfortunately, it's not working. How do I fix this code:
>
> Private Sub Print_this_record_Click()
>
> Dim strDocName As String
> Dim strWhere As String
>    strDocName = "R1-1 GPS_GeneralInfo"
>    strWhere = "[StudentID]=" & Me!StudentID
>    DoCmd.OpenReport strDocName, acPreview, , strWhere
>
> End Sub
>
>
> I need to print out one StudentID for the report R1-1 GPS_GeneralInfo. 
> When
> I click on the button, a popup box with the Student CG2002 appears.
>
> Thanks for your help in advance. 

0
Allen
4/10/2010 2:34:14 AM
Should I be using the primary key or can I use any variable?

Thank you.


"Allen Browne" wrote:

> It seems your student code field is a text field, not a number field. You 
> will therefore need to add quotes:
>     strWhere = "[StudentID]=""" & Me!StudentID & """"
> 
> For an explanation of the quotes, see:
>     Quotation marks within quotes
> at:
>     http://allenbrowne.com/casu-17.html
> 
> -- 
> Allen Browne - Microsoft MVP.  Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
> 
> 
> "forest8" <forest8@discussions.microsoft.com> wrote in message 
> news:A5AD81BD-2356-4B60-B6DD-D0B71088563B@microsoft.com...
> > Hi
> >
> > This is the code I have entered in the event procedure to print a single
> > record.
> >
> > Unfortunately, it's not working. How do I fix this code:
> >
> > Private Sub Print_this_record_Click()
> >
> > Dim strDocName As String
> > Dim strWhere As String
> >    strDocName = "R1-1 GPS_GeneralInfo"
> >    strWhere = "[StudentID]=" & Me!StudentID
> >    DoCmd.OpenReport strDocName, acPreview, , strWhere
> >
> > End Sub
> >
> >
> > I need to print out one StudentID for the report R1-1 GPS_GeneralInfo. 
> > When
> > I click on the button, a popup box with the Student CG2002 appears.
> >
> > Thanks for your help in advance. 
> 
> .
> 
0
Utf
4/10/2010 5:14:01 AM
Whatever value you use should be unique. This is generally a primary key 
field/value.

-- 
Duane Hookom
MS Access MVP


"forest8" <forest8@discussions.microsoft.com> wrote in message 
news:26610B47-A4F0-4629-8812-07F72B3CD73C@microsoft.com...
> Should I be using the primary key or can I use any variable?
>
> Thank you.
>
>
> "Allen Browne" wrote:
>
>> It seems your student code field is a text field, not a number field. You
>> will therefore need to add quotes:
>>     strWhere = "[StudentID]=""" & Me!StudentID & """"
>>
>> For an explanation of the quotes, see:
>>     Quotation marks within quotes
>> at:
>>     http://allenbrowne.com/casu-17.html
>>
>> -- 
>> Allen Browne - Microsoft MVP.  Perth, Western Australia
>> Tips for Access users - http://allenbrowne.com/tips.html
>> Reply to group, rather than allenbrowne at mvps dot org.
>>
>>
>> "forest8" <forest8@discussions.microsoft.com> wrote in message
>> news:A5AD81BD-2356-4B60-B6DD-D0B71088563B@microsoft.com...
>> > Hi
>> >
>> > This is the code I have entered in the event procedure to print a 
>> > single
>> > record.
>> >
>> > Unfortunately, it's not working. How do I fix this code:
>> >
>> > Private Sub Print_this_record_Click()
>> >
>> > Dim strDocName As String
>> > Dim strWhere As String
>> >    strDocName = "R1-1 GPS_GeneralInfo"
>> >    strWhere = "[StudentID]=" & Me!StudentID
>> >    DoCmd.OpenReport strDocName, acPreview, , strWhere
>> >
>> > End Sub
>> >
>> >
>> > I need to print out one StudentID for the report R1-1 GPS_GeneralInfo.
>> > When
>> > I click on the button, a popup box with the Student CG2002 appears.
>> >
>> > Thanks for your help in advance.
>>
>> .
>> 
0
Duane
4/10/2010 5:41:02 AM
Reply:

Similar Artilces:

Problems saving a worksheet with Links
Does anyone know how I can resolve this issue ... I have a directory which contains 129 worksheets which have links to external data (in a Master Spreadsheet) -- I need to copy these files into a New Directory, but kee the Master Spreadsheet (which they are linked to) in the original location. If I do a simple Cut & Past, the Reference Link to the Master Spreadsheet gets moved to the New Directory (where the file does not exist), but if I open the worksheet (in the original directory/location) and Save As to the New Directory, the worksheet saved in the New Directory maintains its link t...

Printing Multiple Receipts at a Time From Journal
Hey guys, Is there a way to print multiple journaled receipts at a time? Say all receipts for a batch or by date or other criteria? Thanks Tom, Not that I've seen. -- = Get Secure! - www.microsoft.com/security You must be using Outlook Express or some other type of newsgroup reader to see and download the file attachment. If you are not using a reader, follow the link below to setup Outlook Express. Click on "Open with newsreader" under the MS Retail Management System on the right. http://tinyurl.com/75bgz ========== "Tom Bombadill" <Genius_pos...

RPC over HTTP problem #3
Hi, All! My network configuration: DC1, DC2 and MX (MS Exchange 2003, sp1). All of them Windows Server 2003. What was done: In the registry on dc1 and dc2 was created a new key: "NSPI Interface protocol sequences" with value: ncacn_http:6004. MX was promoted to be a GC. Installed RPC over HTTP windows component. MX was changed to be RPC-HTTP back-end server. On the MX Default Web Site was installed cerificate from the local authority running on DC2. On the RPC virtual directory anonymous access and integrated windows authentication were disabled. In the registry of MX the key HK...

Convert single colum/multiple rows to multiple colums.
Hi, I have a .dat file when opened with Excel it has 1 column and 7 rows per entry. I would like to delete some rows and convert the rest to something like. Any chance this can be done. It's quite large. 51,793 rows. TIA Jeff Col 1 Col 2 Col 3 Name Date Lenny Kravitz - 2000 - Greatest Hits -- Table: {2} { "music" "Name", "06/04/2008", "Lenny Kravitz - 2000 - Greatest Hits", }, --Table: {3} etc. etc. ...

Computer Check Printing
Computer Checks Edit List is for a check run for one country (all the vendors in that countrY), but the vendors from another country show up as zero dollars. Any idea how to prevent this? It does not appear to be related to KB# 874437, as electronic payments are not used. Thanks in advance. ...

Tax software report
I am unable to view any of my "Insurance : Health" category transactions when I run the "Tax software report" in the Reports section. To be sure, I confirmed that I previously check the tax form, Schedule A, and Doctors - medicine - etc. tax line in the tax manager. The error seems most perculiar given all of my "Healthcare" category transactions are viewable when I run the same report. Any suggestions? ...

Printing Multiple Copies #4
Hi all - I am using Vista Business and Publisher 2007 from the Office 2007 Small Business package. No matter what type of publication or template I use I can only print single copies. Most recently I tried to print 30 copies of a single page flyer and had to do it a single copy at a time. If I go to File|Print and set the number of copies to 30, I still get a single copy only. Does anyone have any thoughts? Thanks -- Andrew Aitchison (amhsn@nospam.sympatico.ca) Is your printer driver current? What is the default in the printing preferences in the control panel printer folder? ...

Outlook 2003: Print address book
I'm running Outlook 2003 as a stand alone program without a network. I can't print the address book. The address book menu does not offer any print options including those found in the Help and Support and the MS Knowledge Base. It also doesn't offer the option to export/import. What am I missing here? Operating Windows XP Home SP2, IE 6 SP2, Outlook 2003. Thanks for any suggestion -- Phil pdischert@iname.com There is no address book in Outlook. There are lots of choices for ways to print your Contacts Folder: http://www.slipstick.com/contacts/print.htm -- Russ V...

http://crm/Reports vs. http://crm/Reportserver
I have several MS CRM reports residing on a SQL Server 2005 that were migrated from 3.0. I can access the reports via the following url: http://crm/Reports then clicking the folder and opening up a report. However, When I try and use http://crm/Reportserver and click on the reports I see the same folder and reports but I get an error message (below) and cannot open any reports? I believe this to be a SRS issue. In the following the GUID appears to be the link and the reports are in a 4.0 folder. Wednesday, April 02, 2008 11:38 AM 23166 {5a8355f1-e300- dd11-a47f-001aa03779ca} ...

Send/Receive Problem
I am using Outlook 2002 on an XP platform. I cannot get Outlook to check for Email at regular intervals. I have the my Outlook set to Send and Receive all my accounts every 10 minutes but nothing happens. The only way I can receive Emails is by manually using the Send/Recv button or pressing F9. Can anyone offer any help. In case it is relevant I am using Norton Internet Security 2003. PWS Not sure it it Yor problem, but Outlook has some problems with Noroton Antivirus runing and chekking e-mails. As far as I know, Outlook may stop recieving e-mails from POP3 servers due to very le...

Printing Non-Avery labels with Zebra TLP-3843
Hello. I'm trying to figure out the best way to print labels and tags for jewelry products using the Zebra 3843...example would be a rat-tail label (overall size: 9/16 x 4 7/16 with printable area of 9/16 x 2 1/2")...one half would be for bar code and other half would be for ILC description, price and store name. Is the label designer capable of doing this if you build a label from scratch? When I try to open the existing Zebra .lbl template it says "BarcodeBlaster style labels can not be edited with the Label Editor. See Store Operations documentation for assistance ...

Excel problem #3
I am attaching an excel file where i have a problem In the file are 2 sheets, Main & second I want to get data from second sheet to the main sheet by a formula by which the amount in the total column will be posted in the second sheet falling under various dates. I have done for 6 sept 2003 by way of example I do not know any formula by which i can do this automatically Please help me Attachment filename: example.xls Download attachment: http://www.excelforum.com/attachment.php?postid=444742 --- Message posted from http://www.ExcelForum.com/ Hi one way: ...

Sync net folder problem
I am sharing my calendar to my workmate with net folder. My PC is Win XP and Office 2000 and my workmate's is Win 98 and also Office 2000. I always find that My calender can't be updated from my workmate when I return office after I've taken my notebook for a few days. Can't net folder sync. data offline? Thx. your attention. Ken So Net Folders uses e-mail messages to send updates between computers so naturally you would have to be connected to your e-mail to get any updates. When you leave the office and are not connected you won't get any updates but as soon as ...

chart line style problem
I am making a scatter chart (with lines) in Excel 2007 under Vista. I can select a line style, for example, long dashes. However, if I try to change the axis (change from "automatic" to "fixed" on the horizontal axis), the line on the chart immediately becomes solid again. The legend still shows the proper dashing. I can get the dashing partly back by making the line thinner, but only where the variation is fastest - regions where the derivative is near zero are still solid even for thin lines. I'll appreciate any help! frank I was not able to reproduce this. Can you...

Printing Word and excel documents via excel vba
I have a document that has some Excel and some word content i would like to use excel vba to print both a page from word and then a page from excel. I know how to select and open the word document, however i cant find any code to print page X from word. basically i need to: print page 1 of c:\xx\document1.doc print page1 of sheet1 of c:\yy\excelwkbk1.xls print page 2 of c:\xx\document1.doc print page2 of sheet1 of c:\yy\excelwkbk1.xls and so on it will require moving between word and excel - the excel bit i get, but getting back to excel from word, and printing out in word is slightly more...

auto forward problems
I setup a 'contact' for 5 existing users in Exchange 5.5 Administrator. I give the contacts the desired SMTP address where they want their mail forwarded to. I set the corresponding 'contact' as the 'alternate recipient' for each of the 5 as detailed in Q255697. 2 of 5 work, the other 3 do not. When sending to each of the 5, 3 return undeliverable stating "A configuration error in the e-mail system caused the message to bounce between two servers or to be forwarded between two recipients." Any ideas? -adam Adam SK wrote: > I setup a 'con...

Exchange 2003 with SP2 problems...
I installed the SP2 for exchange 2003 server tonight, and I'm getting some problems. I added the registry key to increase the DB size to 30GB per the instructions, but I don't get a confirmation in eventid 1216 as it says I should. In fact, the message in eventid 1216 looks mised up. See insert: The Exchange store '16384' is limited to First Storage Group\Mailbox Store (ATL-SBS) GB. The current physical size of this database (the ..edb file and the .stm file) is %3 GB. If the physical size of this database minus its logical free space exceeds the limit of First Storage Gro...

Print Vertical Banner in Pub 2000
Is it possible to print a vertically oriented banner with Publisher 2000? I have made many horizontally oriented banners, and would like to attempt a vertically oriented one. Any tips? Help... ...

Print from Outlook to Avery Rolodex Cards
I am unable to find any way to print my Outlook contacts list on Avery Small Rotary Cards #8385. Please advise. And thanks much. S ...

small problem
hi every body; i wrote a program that it has error ;plz help me :( using System; namespace ConsoleApplication45 { class Program { static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("***********"); for (int i = 0; i < 1008; i++) { Console.BackgroundColor = ConsoleColor.DarkCyan; Console.Write(" "); } move(); // ***********error is for here***********************************************...

Active Directory/Exchange problem
All, Before I joined my current employer the admin here upgraded from Exchange 5.5 to Exchange 2000(Box A) and then added another Exchange 2000 box to the organisation(Box B)and migrated the data in Box A to Box B. Box B is now the working exchange server and Box A is no longer used. The problem is that if I actually shut down Box A I can add a new user to Active Directory but I am unable to modify a users email/smtp details. All mail can still be transferred with no problems which would lead me to believe that Exchange is Ok but there is some sort of Active Directory link between the two bo...

save as version 2003 problem
I'm working in vba in Access to create and save an Excel file. All's good except that one of the workstations this is runnign on is using Office 2007. I'm developing in 2003 and all the other workstatiosn they have are using 2003. It's very important that the files be saved in 2003 format. When I do this, it runs fine and saves as 97/95 objExcelBk.SaveAs sTempPath & sExcelFileName, xlExcel9795 ','56 = xl 2000/2003 I read online in a forum post that "56" is the correct code for saving as 2003 but that's when the code is written in 20...

Font problem with Office 2004 for mac
I have Tiger, whenever I try to Launch any Office program, as the the menu loads to 'optimizing font menu performance' It pops up with 'The font " " has been corrupted and should be removed'. It does this with MANY fonts, many of which I don't even have in my font folder. It does this every time during the program start, and most times even if I go through clicking ok 40-60 times it will sometimes freeze up anyway. Anyway to fix, get around this problem? Please email me at madefornothing@yahoo.com. Hi, this problem affects quite a few users, and there'...

form and query problem. please help.
All tables are linked with weak entities. However, when i enter data on the form I can't get it to let me enter more than one partipicant without access generating a new invoice id. however i need one invoice to many participants. It wont work and i have no idea what to do at this point. in addition the workshop will not let me add workshop to invoice. this is a small mdb and i'd like to email it to anyone who can assist me with the relationships as I think this is the problem but I don't know what to do. please help me. INVOICE invoiceNO - autonumber invoice prices WORKSHOP wo...

Hidden log on problem
On our XP Home laptop I have 2 users on the welcome screen, while my admin account uses (ctrl alt del) x2. All is fine until it goes into standby when I am in admin. Then on wake up the welcome screen comes back, but (ctrl alt del) x2 does nothing. I can't see a way to get back into my account without rebooting. Is there another way (opening one of the other accounts is as slow as rebooting)? Cheers, S On Mar 30, 9:26=A0am, "spamlet" <spam.mores...@invalid.invalid> wrote: > On our XP Home laptop I have 2 users on the welcome screen, while my a...