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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|