A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Having problems printing a single report



 
 
Thread Tools Display Modes
  #1  
Old April 10th, 2010, 01:54 AM posted to microsoft.public.access.reports
forest8
external usenet poster
 
Posts: 196
Default 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.
  #2  
Old April 10th, 2010, 03:34 AM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default Having problems printing a single report

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" wrote in message
...
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.


  #3  
Old April 10th, 2010, 06:14 AM posted to microsoft.public.access.reports
forest8
external usenet poster
 
Posts: 196
Default Having problems printing a single report

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" wrote in message
...
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.


.

  #4  
Old April 10th, 2010, 06:41 AM posted to microsoft.public.access.reports
Duane Hookom[_4_]
external usenet poster
 
Posts: 316
Default Having problems printing a single report

Whatever value you use should be unique. This is generally a primary key
field/value.

--
Duane Hookom
MS Access MVP


"forest8" wrote in message
...
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" wrote in message
...
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.


.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:54 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.