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  

Print report from command button



 
 
Thread Tools Display Modes
  #1  
Old August 10th, 2009, 08:55 PM posted to microsoft.public.access.reports
Elizabeth
external usenet poster
 
Posts: 208
Default Print report from command button

I am trying to add a button to a form that will print a report showing detail
from that particular form. I have written a report that will show all of the
information as it would be seen on the form screen. However, I am having
trouble getting it to print the information for just one job. I have set up
an event procedure as follows:

Private Sub Print_JobEntry_Click()
On Error GoTo Err_Print_JobEntry_Click

Dim MyWhereCondition As String

MyWhereCondition = "JobID" = " & Me.JobID"
DoCmd.OpenReport " JobEntryJobQuery ", acViewPreview, , MyWhereCondition

Exit_Print_JobEntry_Click:
Exit Sub

Err_Print_JobEntry_Click:
MsgBox Err.Description
Resume Exit_Print_JobEntry_Click

End Sub

I can get the report to come up, but it does not have any information on it.
It simply has the labels. I have tried both making the underlying query
have criteria showing only one job and having the query with no criteria.
Can anyone please give me any suggestions on how to fix this so that the
report will actually show the information?
--
Thanks for any help you can give!

Elizabeth
  #2  
Old August 10th, 2009, 09:07 PM posted to microsoft.public.access.reports
Duane Hookom
external usenet poster
 
Posts: 7,177
Default Print report from command button

It's a bit confusing when your report name looks more like a query name.

Assuming JobID is numeric, try remove two quote marks and then some spaces
around the report name:

Private Sub Print_JobEntry_Click()
On Error GoTo Err_Print_JobEntry_Click

Dim MyWhereCondition As String

MyWhereCondition = "JobID = " & Me.JobID
DoCmd.OpenReport "JobEntryJobQuery", acViewPreview, , MyWhereCondition

Exit_Print_JobEntry_Click:
Exit Sub

Err_Print_JobEntry_Click:
MsgBox Err.Description
Resume Exit_Print_JobEntry_Click

End Sub

--
Duane Hookom
Microsoft Access MVP


"Elizabeth" wrote:

I am trying to add a button to a form that will print a report showing detail
from that particular form. I have written a report that will show all of the
information as it would be seen on the form screen. However, I am having
trouble getting it to print the information for just one job. I have set up
an event procedure as follows:

Private Sub Print_JobEntry_Click()
On Error GoTo Err_Print_JobEntry_Click

Dim MyWhereCondition As String

MyWhereCondition = "JobID" = " & Me.JobID"
DoCmd.OpenReport " JobEntryJobQuery ", acViewPreview, , MyWhereCondition

Exit_Print_JobEntry_Click:
Exit Sub

Err_Print_JobEntry_Click:
MsgBox Err.Description
Resume Exit_Print_JobEntry_Click

End Sub

I can get the report to come up, but it does not have any information on it.
It simply has the labels. I have tried both making the underlying query
have criteria showing only one job and having the query with no criteria.
Can anyone please give me any suggestions on how to fix this so that the
report will actually show the information?
--
Thanks for any help you can give!

Elizabeth

  #3  
Old August 11th, 2009, 01:14 PM posted to microsoft.public.access.reports
Elizabeth
external usenet poster
 
Posts: 208
Default Print report from command button

I renamed the report to take out the query part of the name. I then took out
the spaces around the report name. That works fine except that I still have
a report with only headers. I tried deleting the quotations from the JobID,
but received a syntax error. The JobID is a combination of numeric and alpha
characters. Any other suggestions?
--
Thanks for any help you can give!

Elizabeth


"Duane Hookom" wrote:

It's a bit confusing when your report name looks more like a query name.

Assuming JobID is numeric, try remove two quote marks and then some spaces
around the report name:

Private Sub Print_JobEntry_Click()
On Error GoTo Err_Print_JobEntry_Click

Dim MyWhereCondition As String

MyWhereCondition = "JobID = " & Me.JobID
DoCmd.OpenReport "JobEntryJobQuery", acViewPreview, , MyWhereCondition

Exit_Print_JobEntry_Click:
Exit Sub

Err_Print_JobEntry_Click:
MsgBox Err.Description
Resume Exit_Print_JobEntry_Click

End Sub

--
Duane Hookom
Microsoft Access MVP


"Elizabeth" wrote:

I am trying to add a button to a form that will print a report showing detail
from that particular form. I have written a report that will show all of the
information as it would be seen on the form screen. However, I am having
trouble getting it to print the information for just one job. I have set up
an event procedure as follows:

Private Sub Print_JobEntry_Click()
On Error GoTo Err_Print_JobEntry_Click

Dim MyWhereCondition As String

MyWhereCondition = "JobID" = " & Me.JobID"
DoCmd.OpenReport " JobEntryJobQuery ", acViewPreview, , MyWhereCondition

Exit_Print_JobEntry_Click:
Exit Sub

Err_Print_JobEntry_Click:
MsgBox Err.Description
Resume Exit_Print_JobEntry_Click

End Sub

I can get the report to come up, but it does not have any information on it.
It simply has the labels. I have tried both making the underlying query
have criteria showing only one job and having the query with no criteria.
Can anyone please give me any suggestions on how to fix this so that the
report will actually show the information?
--
Thanks for any help you can give!

Elizabeth

  #4  
Old August 11th, 2009, 01:19 PM posted to microsoft.public.access.reports
Duane Hookom
external usenet poster
 
Posts: 7,177
Default Print report from command button

If the JobID field is text, try:

Private Sub Print_JobEntry_Click()
On Error GoTo Err_Print_JobEntry_Click

Dim MyWhereCondition As String
Dim strReportName as String
strReportName = "JobEntry....Whatever"
MyWhereCondition = "JobID = """ & Me.JobID & """"
DoCmd.OpenReport strReportName, acViewPreview, , MyWhereCondition

Exit_Print_JobEntry_Click:
Exit Sub

Err_Print_JobEntry_Click:
MsgBox Err.Description
Resume Exit_Print_JobEntry_Click

End Sub


--
Duane Hookom
Microsoft Access MVP


"Elizabeth" wrote:

I renamed the report to take out the query part of the name. I then took out
the spaces around the report name. That works fine except that I still have
a report with only headers. I tried deleting the quotations from the JobID,
but received a syntax error. The JobID is a combination of numeric and alpha
characters. Any other suggestions?
--
Thanks for any help you can give!

Elizabeth


"Duane Hookom" wrote:

It's a bit confusing when your report name looks more like a query name.

Assuming JobID is numeric, try remove two quote marks and then some spaces
around the report name:

Private Sub Print_JobEntry_Click()
On Error GoTo Err_Print_JobEntry_Click

Dim MyWhereCondition As String

MyWhereCondition = "JobID = " & Me.JobID
DoCmd.OpenReport "JobEntryJobQuery", acViewPreview, , MyWhereCondition

Exit_Print_JobEntry_Click:
Exit Sub

Err_Print_JobEntry_Click:
MsgBox Err.Description
Resume Exit_Print_JobEntry_Click

End Sub

--
Duane Hookom
Microsoft Access MVP


"Elizabeth" wrote:

I am trying to add a button to a form that will print a report showing detail
from that particular form. I have written a report that will show all of the
information as it would be seen on the form screen. However, I am having
trouble getting it to print the information for just one job. I have set up
an event procedure as follows:

Private Sub Print_JobEntry_Click()
On Error GoTo Err_Print_JobEntry_Click

Dim MyWhereCondition As String

MyWhereCondition = "JobID" = " & Me.JobID"
DoCmd.OpenReport " JobEntryJobQuery ", acViewPreview, , MyWhereCondition

Exit_Print_JobEntry_Click:
Exit Sub

Err_Print_JobEntry_Click:
MsgBox Err.Description
Resume Exit_Print_JobEntry_Click

End Sub

I can get the report to come up, but it does not have any information on it.
It simply has the labels. I have tried both making the underlying query
have criteria showing only one job and having the query with no criteria.
Can anyone please give me any suggestions on how to fix this so that the
report will actually show the information?
--
Thanks for any help you can give!

Elizabeth

  #5  
Old August 11th, 2009, 01:44 PM posted to microsoft.public.access.reports
Elizabeth
external usenet poster
 
Posts: 208
Default Print report from command button

I have it working now. Thank you so much for your help!

Elizabeth


"Duane Hookom" wrote:

If the JobID field is text, try:

Private Sub Print_JobEntry_Click()
On Error GoTo Err_Print_JobEntry_Click

Dim MyWhereCondition As String
Dim strReportName as String
strReportName = "JobEntry....Whatever"
MyWhereCondition = "JobID = """ & Me.JobID & """"
DoCmd.OpenReport strReportName, acViewPreview, , MyWhereCondition

Exit_Print_JobEntry_Click:
Exit Sub

Err_Print_JobEntry_Click:
MsgBox Err.Description
Resume Exit_Print_JobEntry_Click

End Sub


--
Duane Hookom
Microsoft Access MVP


"Elizabeth" wrote:

I renamed the report to take out the query part of the name. I then took out
the spaces around the report name. That works fine except that I still have
a report with only headers. I tried deleting the quotations from the JobID,
but received a syntax error. The JobID is a combination of numeric and alpha
characters. Any other suggestions?
--
Thanks for any help you can give!

Elizabeth


"Duane Hookom" wrote:

It's a bit confusing when your report name looks more like a query name.

Assuming JobID is numeric, try remove two quote marks and then some spaces
around the report name:

Private Sub Print_JobEntry_Click()
On Error GoTo Err_Print_JobEntry_Click

Dim MyWhereCondition As String

MyWhereCondition = "JobID = " & Me.JobID
DoCmd.OpenReport "JobEntryJobQuery", acViewPreview, , MyWhereCondition

Exit_Print_JobEntry_Click:
Exit Sub

Err_Print_JobEntry_Click:
MsgBox Err.Description
Resume Exit_Print_JobEntry_Click

End Sub

--
Duane Hookom
Microsoft Access MVP


"Elizabeth" wrote:

I am trying to add a button to a form that will print a report showing detail
from that particular form. I have written a report that will show all of the
information as it would be seen on the form screen. However, I am having
trouble getting it to print the information for just one job. I have set up
an event procedure as follows:

Private Sub Print_JobEntry_Click()
On Error GoTo Err_Print_JobEntry_Click

Dim MyWhereCondition As String

MyWhereCondition = "JobID" = " & Me.JobID"
DoCmd.OpenReport " JobEntryJobQuery ", acViewPreview, , MyWhereCondition

Exit_Print_JobEntry_Click:
Exit Sub

Err_Print_JobEntry_Click:
MsgBox Err.Description
Resume Exit_Print_JobEntry_Click

End Sub

I can get the report to come up, but it does not have any information on it.
It simply has the labels. I have tried both making the underlying query
have criteria showing only one job and having the query with no criteria.
Can anyone please give me any suggestions on how to fix this so that the
report will actually show the information?
--
Thanks for any help you can give!

Elizabeth

 




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 07:20 AM.


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