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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|